This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sleep method  RSS feed

 
memati bas
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anyone explain the exact usage purpose of the sleep method in thread ?
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by memati bas:
Hi,
Can anyone explain the exact usage purpose of the sleep method in thread ?


Causes the current executing thread to sleep for the specified time(in milliseconds) but it do not lose ownership of any monitors.
 
memati bas
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you imply by saying " sleep " ??
Please explain...
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Google:

Suspend process execution pending occurrence of an event; the term �block� is also used.


Basically, it means that the current thread does nothing for that time period (simply waits/blocks).
 
memati bas
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh thanks,
I think I kept the idea now...
 
amod gole
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi memati bas,

using sleep method we are causing current to sleep for specific time
and once that thread is sleep it leaves a cpu and another thread can start their excecution

rememeber(at any instance of time cpu executes only one process)
 
memati bas
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, thanks amod gole.
It is really explanaitory...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!