I am gray

Main | I18N of NetBeans... »
Středa III 19, 2008

Default RequestProcessor in NetBeans can not cancel running Tasks

RequestProcessor is quite useful class for programming in NetBeans. You are not supposed to create your own threads (quite similar limitation is common for different managed environments such as application servers) and RequestProcessor.Task is quite comfortable (and a bit more high level) way to perform concurrent tasks.
The common pattern to use it is
RequestProcessor.Task myTask = RequestProcessor.getDefault().post(aRunnable)
This is a pretty good way, until you try myTask.cancel(). In such a situation, there are two possibilities. If the myTask has not started yet, it is canceled and will not be started ever. If it has already started, it is not interrupted.
So if you want to start some longer tasks and you would like to cancel even when already running, you must create your own RequestProcessor using this constructor with the (last) parameter interruptThread set to true.

Comments:

Thanks for posting this clarification. This helped me totally !

Posted by vadiraj on červenec 14, 2008 at 10:39 dop. CEST #

Post a Comment:
  • HTML Syntax: NOT allowed