org.directwebremoting.dwrp
Class ThreadWaitSleeper

java.lang.Object
  extended by org.directwebremoting.dwrp.ThreadWaitSleeper

public class ThreadWaitSleeper
extends java.lang.Object

The simplest type of Sleeper that just uses Object.wait() and Object.notify() to halt a Thread and restart it.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Constructor Summary
ThreadWaitSleeper()
           
 
Method Summary
 void goToSleep(java.lang.Runnable onAwakening)
          'halt' the current execution in some way.
 void wakeUp()
          This method should attempt to resume the execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadWaitSleeper

public ThreadWaitSleeper()
Method Detail

goToSleep

public void goToSleep(java.lang.Runnable onAwakening)
'halt' the current execution in some way. This method should be the last meaningful thing that is done on a request, and work that needs to be done before completion should be done in a Runnable so the system can schedule it at an appropriate time.

Parameters:
onAwakening - The action to take when wakeUp() is called

wakeUp

public void wakeUp()
This method should attempt to resume the execution. It is possible that this method will be called more than once at the same time so Sleepers should be prepared take steps to be woken only once.