站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.0.0

RequestProcessor.Task (NetBeans Utilities API) - NetBeans API Javadoc 5.0.0

 

org.openide.util
Class RequestProcessor.Task

java.lang.Object
  extended byorg.openide.util.Task
      extended byorg.openide.util.RequestProcessor.Task
All Implemented Interfaces:
Cancellable, Runnable
Enclosing class:
RequestProcessor

public final class RequestProcessor.Task
extends Task
implements Cancellable

The task describing the request sent to the processor. Cancellable since 4.1.


Field Summary
 
Fields inherited from class org.openide.util.Task
EMPTY
 
Method Summary
 boolean cancel()
          Removes the task from the queue.
 int getDelay()
          Getter for amount of millis till this task is started.
 int getPriority()
          Current priority of the task.
 void run()
          Start the task.
 void schedule(int delay)
          (Re-)schedules a task to run in the future.
 void setPriority(int priority)
          Changes the priority the task will be performed with.
 String toString()
           
 void waitFinished()
          This method is an implementation of the waitFinished method in the RequestProcessor.Task.
 boolean waitFinished(long timeout)
          Enhanced reimplementation of the Task.waitFinished(long) method.
 
Methods inherited from class org.openide.util.Task
addTaskListener, isFinished, notifyFinished, notifyRunning, removeTaskListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

run

public void run()
Description copied from class: Task
Start the task. When it finishes (even with an exception) it calls Task.notifyFinished(). Subclasses may override this method, but they then need to call Task.notifyFinished() explicitly.

Note that this call runs synchronously, but typically the creator of the task will call this method in a separate thread.

Specified by:
run in interface Runnable
Overrides:
run in class Task

getDelay

public int getDelay()
Getter for amount of millis till this task is started.

Returns:
amount of millis

schedule

public void schedule(int delay)
(Re-)schedules a task to run in the future. If the task has not been run yet, it is postponed to the new time. If it has already run and finished, it is scheduled to be started again. If it is currently running, it is nevertheless left to finish, and also scheduled to run again.

Parameters:
delay - time in milliseconds to wait (starting from now)

cancel

public boolean cancel()
Removes the task from the queue.

Specified by:
cancel in interface Cancellable
Returns:
true if the task has been removed from the queue, false it the task has already been processed

getPriority

public int getPriority()
Current priority of the task.


setPriority

public void setPriority(int priority)
Changes the priority the task will be performed with.


waitFinished

public void waitFinished()
This method is an implementation of the waitFinished method in the RequestProcessor.Task. It check the current thread if it is request processor thread and in such case runs the task immediatelly to prevent deadlocks.

Overrides:
waitFinished in class Task

waitFinished

public boolean waitFinished(long timeout)
                     throws InterruptedException
Enhanced reimplementation of the Task.waitFinished(long) method. The added semantic is that if one calls this method from another task of the same processor, and the task has not yet been executed, the method will immediatelly detect that and throw InterruptedException to signal that state.

Overrides:
waitFinished in class Task
Parameters:
timeout - the amount of time to wait
Returns:
true if the task was finished successfully during the timeout period, false otherwise
Throws:
InterruptedException - if waiting has been interrupted or if the wait cannot succeed due to possible deadlock collision
Since:
5.0

toString

public String toString()
Overrides:
toString in class Task

 

Built on May 3 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.