Saturday 19 July 2014

wait() Vs sleep()

  1. Wait() must be called in synchronization context, otherwise IllegalMonitorStateException thrown.
  2. wait operates on Object and defined in Object class while sleep operates on current Thread and defined in java.lang.Thread class.
  3. Wait() method releases the lock it holds, where as sleep method not.
  4. Sleep is static method, where as wait is non static.


Related links
                                            

                                                          Home

No comments:

Post a Comment