草庐IT

threaded_comments

全部标签

java - Dag 调度程序事件循环 java.lang.OutOfMemoryError : unable to create new native thread

运行5-6小时后,我从spark-driver程序中收到以下错误。我正在使用Ubuntu16.04LTS和open-jdk-8。Exceptioninthread"ForkJoinPool-50-worker-11"Exceptioninthread"dag-scheduler-event-loop"Exceptioninthread"ForkJoinPool-50-worker-13"java.lang.OutOfMemoryError:unabletocreatenewnativethreadatjava.lang.Thread.start0(NativeMethod)atjava

Java:测试线程访问 "not thread-safe"方法

我在SwingJava应用程序中解决线程问题的策略是将方法分为三种类型:应该由GUI线程访问的方法。这些方法不应该阻塞并且可以调用swing方法。不是线程安全的。应由非GUI线程访问的方法。基本上这适用于所有(潜在的)阻塞操作,例如磁盘、数据库和网络访问。他们不应该调用swing方法。不是线程安全的。两者都可以访问的方法。这些方法必须是线程安全的(例如同步的)我认为这对于通常只有两个线程的GUI应用程序来说是一种有效的方法。解决问题确实有助于减少竞争条件的“表面积”。当然,需要注意的是,您绝不会不小心从错误的线程中调用方法。我的问题是关于测试的:是否有测试工具可以帮助我检查是否从正确的

java - Thread.currentThread().sleep(timer) vs Thread.sleep(time);

这个问题在这里已经有了答案:关闭12年前。PossibleDuplicate:Java:Thread.currentThread().sleep(x)vs.Thread.sleep(x)...之间有什么区别Thread.currentThread().sleep(time)和Thread.sleep(time);还有一件事是我可以在不使用线程类的情况下延迟程序的任何其他方法...

java - 如何在单元测试中避免 Thread.sleep?

假设我有以下应该测试的方法:@AutowiredprivateRoutingServiceroutingservice;publicvoidmethodToBeTested(){ObjectobjectToRoute=initializeObjectToRoute();if(someConditions){routingService.routeInOneWay(objectToRoute);}else{routingService.routeInAnotherWay(objectToRoute);}}在这种情况下,RoutingService在单独的线程中运行,因此在它的构造函数中我

java - 请解释 Thread run() 和 start() 方法的输出

请解释以下代码的输出:如果我调用th1.run(),输出是:EXTENDSRUN>>RUNNABLERUN>>如果我调用th1.start(),输出是:RUNNABLERUN>>EXTENDSRUN>>为什么会出现这种不一致?请解释。classThreadExampleextendsThread{publicvoidrun(){System.out.println("EXTENDSRUN>>");}}classThreadExampleRunnableimplementsRunnable{publicvoidrun(){System.out.println("RUNNABLERUN>>

java - 如何避免使用 Thread.Sleep

在我下载最新版本的Netbeans之前,我从未考虑过Thread.Sleep的使用。Netbeans现在警告您不要使用Thread.Sleep。因此,我对该主题进行了一些研究,发现有人说您只需要将Thread.Sleep用于调试/测试目的,如果您在任何其他时间使用它,您的代码就会写得不好。所以我的问题是在以下情况下如何避免使用Thread.Sleep。我编写了一个与另一个应用程序交互的服务器应用程序。服务器有两个线程:处理来自套接字的数据并发回其他信息或只是简单的确认。这是主线程。启动套接字线程后,它会进入一个无限期的while循环。在这个while循环中,我检查以确保套接字线程仍然处

java.rmi.ServerException : RemoteException occurred in server thread (ClassNotFoundException) 异常

以下方法:privatevoidstartServer(){//snippetthatstartstheserveronthelocalmachinetry{RemoteMethodImplimpl=newRemoteMethodImpl();Naming.rebind("Illusive-Server",impl);}catch(Exceptionexc){JOptionPane.showMessageDialog(this,"Problemstartingtheserver","Error",JOptionPane.ERROR_MESSAGE);System.out.println

java - Thread.sleep 等待时间超过预期

以下代码:longmsBefore=System.currentTimeMillis();//Thread.currentThread().setPriority(Thread.MAX_PRIORITY);try{Thread.sleep(200);}catch(InterruptedExceptione){}System.out.println("Time:"+(System.currentTimeMillis()-msBefore));打印:Time:578Time:594Time:625Time:640Time:641Time:609Time:625Time:625Time:61

java - hibernate 异常 : Could not obtain transaction-synchronized Session for current thread

我遇到错误:Exceptioninthread"main"org.hibernate.HibernateException:Couldnotobtaintransaction-synchronizedSessionforcurrentthread主要ppService.deleteProductPart(cPartId,productId);@Service("productPartService")@OverridepublicvoiddeleteProductPart(intcPartId,intproductId){productPartDao.deleteProductPart

java - JavaFX 中的复杂并发 : using ObservableLists and Properties from multiple worker threads

我有多个工作线程和一个JavaFXGUI,它报告这些线程中发生的事情。线程之间共享的数据很多,需要可视化。所以我使用ObservableList和Property能够轻松地在JavaFX中显示数据。我制作了一个小示例应用程序来展示与我的应用程序中发生的情况类似的内容。它有2个列表,工作线程将数据从一个列表移动到另一个列表。状态字符串保持最新。完整的示例代码可以在http://codetidy.com/6569/找到(此代码会崩溃,稍后查看)这是共享的ObservableList的&属性:privateObservableListnewItems;privateObservableLis