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

Recommended Answers

All 4 Replies

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

Thanx Man..... Solved....

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.

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.... :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.