Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sleep method

 
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...
 
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!