File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Running threads in Sequence Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Running threads in Sequence" Watch "Running threads in Sequence" New topic

Running threads in Sequence

Deep Gagan

Joined: Aug 03, 2007
Posts: 11

I have a question, suppose we have 100 threads e.g T1, T2, T3 . . . T100. I want threads to run in sequence. First T1 completes then T2, then T3….at last T100. Is there any way to implement this ?
You can say each thread prints its Name .
So my output should be
T1 T2 T3 T4.........T100


Thanks & Regards
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 446

well there is a way but I don't think that will be too much useful

have you heard of the join method on threads?

can you write code using join method?

SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

So basically you want all those thread to run in a single thread. Instead of calling the start method call the run method.
But can you tell us why you created those threads in the first place if you didn't want multi-threaded behaviour.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
I agree. Here's the link:
subject: Running threads in Sequence
It's not a secret anymore!