0

I have placed thread is alive in a loop , so when the thread finish its work so i will start another work.... but this makes program heavier. is there any other method

while(thread1 is alive)
wait


getvalue from thread1 and start thread2
3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Majestics
2

Use the join() method from the Thread class - it waits until the thread has finished. Plenty of examples on the web.

0

Of course, that raises the question of why you are using threads. I mean, if all the main program (or the thread that started that other thread) is going to do is wait until the other thread is finished, then the thread is nothing but extra overhead.

0

there are mulitple threads , not connected with main.... when one thread ends other take its place and then other... Its a practice excerise for checking threads working from different ways.... :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.