• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is this code starting multiple threads

 
Carsten Hoyer
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
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.

 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code generates and starts one new Thread here:


This bit of code causes that new Thread to sleep:

 
Carsten Hoyer
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
R van Vliet
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Carsten Hoyer
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic