This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
This is a very basic Threading question. Does the following code start multiple threads. What I wanted was just make the thread sleep and continue. But using activecount, i can see that the thread number rises.
Carsten Hoyer wrote:Ah, ok i forgot to include a running clause in the method. So in the above example. A new thread is only created when the old thread stops running.
Both bits of your code will never start more than one thread. If I read your question correctly you want to start a new thread as soon as the previous one stops (running == false). If so the code above does not do that.
Joined: Dec 06, 2009
Thanks for reply. No i wanted that behaviour. One thread that goes on and on. What confused was that activecount() would keep increasing. How do I mark the thread solved?