Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Thread

Status
Not open for further replies.

satellite03

IS-IT--Management
Dec 26, 2003
248
IN
does Thread.sleep() release the object lock ? does it same as wait() method ?
 
No, it sleeps the thread for a number of milliseconds - think of it as just sitting in a big "while" loop for a precise about of time.

--------------------------------------------------
Free Database Connection Pooling Software
 
>think of it as just sitting in a big "while" loop for a >precise about of time.
very soothing language!

then what happens when you call wait() ? what does the thread do at that time ? is not the thread sleep at that time!! what it does then ?
 
will you tell me the answer of my next question ?

i dont understand when do i call the ByteArrayOutPutStream . there are already lots of streams available. i am lost in those stream.


 
Relax fella - do I look like paid support ?!!!

I'm not sure what "wait()" does on an object under the covers - it may well call a native "sleep()" - but the difference is that Thread.sleep() just sleeps the thread, and then it resumes - Object.wait() blocks the thread indefintely until notify() is called.

--------------------------------------------------
Free Database Connection Pooling Software
 
satellite03 said:
then what happens when you call wait() ? what does the thread do at that time ? is not the thread sleep at that time!! what it does then ?

Like sedj says, it waits until notify is called. Surely Java has enough in it to learn without wanting to go 'under the covers'. If you are that curious, maybe you want to be reading into the JVM Specification and stuff like that.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
>Relax fella - do I look like paid support ?!!!

sorry, dont think that way. your answers are always very attractive. so i asked one more question.
forget it.

thanks for the enough information.
 
satellite03 :
Its not that you asked another question - its that you baited me to reply after a delay of 6 minutes !

No hard feelings :)

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top