我很难理解如何以及在哪里使用同步方法中的wait()和notify()来让线程等待并用notify()唤醒它。我让它让第一个线程在ping语句之后等待,这样下一个线程也会启动它的ping语句。asking Boy to confirmGirl (ping): got confirmationMonitor.java();
我有一个需求,在一个方法调用中,我想要访问三个不同的集合来检索数据。现在我正在一个接一个地做获取数据的工作。相反,我想创建三个线程,每个线程都应该并行执行。然后在每件事完成后,我想合并结果并将其发送给客户端。 // all the tasks should execute in parallel & finally task1(); task3(
我使用Object.notify和Object.wait来控制线程。at java.lang.Object.notify(Native Method) at java.lang.Thread.run(); // notify the train to let the passengers off
justWait(); //
在startEmployeeProcess()方法中,我启动了一个thread1 (EmployeeThread),在开关中,我调用了thread1.wait() (案例3) System.out.println("*************************FILE WRITER THREAD IS IN WAITPROCESS**********************");
thread1.wait</em