• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is this code starting multiple threads

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic