This week's book giveaway is in the Python forum.
We're giving away four copies of High Performance Python for Data Analytics and have Tiago Rodrigues Antao on-line!
See this thread for details.
Win a copy of High Performance Python for Data Analytics this week in the Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

directly stopping a thread

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could someone tell me which of these methods directly stop a thread:
wait()
start() called on a new thread
sleep()
notify()
yield()
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wait() (within a synchronized code block of course) will cause the thread to stop until it is interrupted.
start() (used with a Thread based object) will in effect branch a new thread off from the currently executing thread. Both threads will run (theoretically) in parallel.
sleep() will make the currently running thread stop executing for a specified period of time, and then continue.
notify() will interrupt a thread that has called wait().
yield() will cause a thread to suspend operation so that other threads of equal or higher priority will be allowed to run by the thread scheduler, which could be the same thread that called the yield() method. This is usually used if a thread is carrying out a complex computation so that other threads can have a chance to run.

Originally posted by Nigel Patching:
Could someone tell me which of these methods directly stop a thread:
wait()
start() called on a new thread
sleep()
notify()
yield()



------------------
Cheers,
RL
 
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic