multithreading - Run Java Threads sequentially -


How do you execute three threads sequentially? For example, thread 1, thread 2, thread 3 is not possible to pass another reference to a thread and the run () method is requested.

The code should be:

  thread 1.start (); Thread2.start (); Thread3.start ();   

and should be excluded

  printing thread 1 printing thread 2 printing thread 3   

using the ThreadPoolExecutor It is possible and even using the blocked queue, but this is also not an acceptable answer.

Use the package in java.util.concurrent. Use more accurate executables. NewSingleThreadExecutor ();

Comments