Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
1.8-beta-3
-
None
-
jdk1.6u16
-
Patch
Description
Sometimes we need to split a huge task to some smaller tasks. The main thread should wait util all these tasks complete their tasks.
The new start DGSM add support for this situation.
Enjoy the patch
The sample code is shown as follows:
import java.util.concurrent.atomic.AtomicBoolean class Test extends GroovyTestCase { public void testThreadStart() { volatile AtomicBoolean thread1Done = new AtomicBoolean(false); volatile AtomicBoolean thread2Done = new AtomicBoolean(false); long thread1SleepMillis = 500; long thread2SleepMillis = 300; long begin = System.currentTimeMillis(); Thread.start( { Thread.sleep(thread1SleepMillis); thread1Done.set(true); }, { Thread.sleep(thread2SleepMillis); thread2Done.set(true); } ); long end = System.currentTimeMillis(); assert thread1Done.get() && thread2Done.get() && ((end - begin) < (thread1SleepMillis + thread2SleepMillis)); } }