org.openide.util
Class RequestProcessor

java.lang.Object
  |
  +--org.openide.util.RequestProcessor

public final class RequestProcessor
extends Object

Request processor that is capable to execute actions in special thread.


Inner Class Summary
 class RequestProcessor.Task
          The task describing the request task send to the processor.
 
Constructor Summary
RequestProcessor()
          Default constructor.
RequestProcessor(String name)
          Constructor.
 
Method Summary
 RequestProcessor.Task create(Runnable run)
          Creates request that can be later started by setting its delay.
static RequestProcessor.Task createRequest(Runnable run)
          Creates request that can be later started by setting its delay.
protected  void finalize()
          When finalized, stops the thread.
 boolean isRequestProcessorThread()
          Tests if the current thread is request processor thread.
 RequestProcessor.Task post(Runnable run)
          This methods asks the request processor to start given runnable immediately.
 RequestProcessor.Task post(Runnable run, int timeToWait)
          This methods asks the request processor to start given runnable after timeToWait milliseconds.
 RequestProcessor.Task post(Runnable run, int timeToWait, int priority)
          This methods asks the request processor to start given runnable after timeToWait milliseconds.
static RequestProcessor.Task postRequest(Runnable run)
          This methods asks the request processor to start given runnable after timeToWait milliseconds.
static RequestProcessor.Task postRequest(Runnable run, int timeToWait)
          This methods asks the request processor to start given runnable after timeToWait milliseconds.
static RequestProcessor.Task postRequest(Runnable run, int timeToWait, int priority)
          This methods asks the request processor to start given runnable after timeToWait milliseconds.
 void stop()
          Stops processing of runnables processor.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestProcessor

public RequestProcessor()
Default constructor.

RequestProcessor

public RequestProcessor(String name)
Constructor.
Parameters:
name - the name to use for the request processor thread
Method Detail

finalize

protected void finalize()
When finalized, stops the thread.
Overrides:
finalize in class Object

post

public RequestProcessor.Task post(Runnable run)
This methods asks the request processor to start given runnable immediately. The default priority is Thread.MIN_PRIORITY.
Parameters:
run - class to run
Returns:
the task to control the request

post

public RequestProcessor.Task post(Runnable run,
                                  int timeToWait)
This methods asks the request processor to start given runnable after timeToWait milliseconds. The default priority is Thread.MIN_PRIORITY.
Parameters:
run - class to run
timeToWait - to wait before execution
Returns:
the task to control the request

post

public RequestProcessor.Task post(Runnable run,
                                  int timeToWait,
                                  int priority)
This methods asks the request processor to start given runnable after timeToWait milliseconds. Given priority is assigned to the request.
Parameters:
run - class to run
timeToWait - to wait before execution
priority - the priority from Thread.MIN_PRIORITY to Thread.MAX_PRIORITY
Returns:
the task to control the request

create

public RequestProcessor.Task create(Runnable run)
Creates request that can be later started by setting its delay. The request is not immediatelly put into the queue. It is planned after setting its delay by setDelay method.
Parameters:
run - action to run in the process
Returns:
the task to control execution of given action

isRequestProcessorThread

public boolean isRequestProcessorThread()
Tests if the current thread is request processor thread. This method could be used to prevent the deadlocks using waitFinished method. Any two tasks created by request processor must not wait for themself.
Returns:
true if the current thread is request processor thread, otherwise false

stop

public void stop()
Stops processing of runnables processor. The currently running runnable is finished and no new is started.

postRequest

public static RequestProcessor.Task postRequest(Runnable run)
This methods asks the request processor to start given runnable after timeToWait milliseconds. The default priority is Thread.MIN_PRIORITY.
Parameters:
run - class to run
Returns:
the task to control the request

postRequest

public static RequestProcessor.Task postRequest(Runnable run,
                                                int timeToWait)
This methods asks the request processor to start given runnable after timeToWait milliseconds. The default priority is Thread.MIN_PRIORITY.
Parameters:
run - class to run
timeToWait - to wait before execution
Returns:
the task to control the request

postRequest

public static RequestProcessor.Task postRequest(Runnable run,
                                                int timeToWait,
                                                int priority)
This methods asks the request processor to start given runnable after timeToWait milliseconds. Given priority is assigned to the request.
Parameters:
run - class to run
timeToWait - to wait before execution
priority - the priority from Thread.MIN_PRIORITY to Thread.MAX_PRIORITY
Returns:
the task to control the request

createRequest

public static RequestProcessor.Task createRequest(Runnable run)
Creates request that can be later started by setting its delay. The request is not immediatelly put into the queue. It is planned after setting its delay by setDelay method.
Parameters:
run - action to run in the process
Returns:
the task to control execution of given action


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.