Home > Software > Java > Core-Java
Interview Questions   Tutorials   Discussions   Programs   

Core-Java - what is the difference between sleep() and Wait()?




290
views
asked marvit August 27, 2014 05:36 AM  

what is the difference between sleep() and Wait()?


           

1 Answers



 
answered By Madhumathi   0  
1.
Synatx :
 public static void sleep(long millis) throws interruptedException 
 
 public final void wait() throws interruptedException 



2. wait releases the lock which it is holding .
    sleep doesnt release the lock .

3.wait() must be called from a synchronized context. 
   sleep() may not be called from a synchronized context. 


flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert