This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 170581 - RequestProcessor.Task.schedule(0) permits concurrent execution
Summary: RequestProcessor.Task.schedule(0) permits concurrent execution
Status: RESOLVED DUPLICATE of bug 40788
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on:
Blocks: 170554
  Show dependency tree
 
Reported: 2009-08-18 22:03 UTC by Jesse Glick
Modified: 2009-08-21 06:07 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2009-08-18 22:03:32 UTC
See discussion in issue #170554 for background. I am aware of the throughput parameter but my expectation would be that
a single task would never be run in multiple threads regardless of throughput, that only _distinct_ tasks would be run
in parallel. This expectation indeed seems to hold - unless you pick the special value 0 for the delay. Example:

import java.util.Random;
import org.openide.util.Exceptions;
import org.openide.util.RequestProcessor;
public class Run implements Runnable {
    public static void main(String[] args) throws InterruptedException {
        RequestProcessor r = RequestProcessor.getDefault();
//        RequestProcessor r = new RequestProcessor("r", 1);
        RequestProcessor.Task t = r.create(new Run());
        int delay = 0;
//        int delay = 1;
        t.schedule(delay);
        t.schedule(delay);
        t.schedule(delay);
        t.schedule(delay);
//        t.waitFinished();
        Thread.sleep(4000);
    }
    public void run() {
        int i = new Random().nextInt(1000);
        System.err.println("start #" +i);
        try {
            Thread.sleep(i);
        } catch (InterruptedException ex) {
            Exceptions.printStackTrace(ex);
        }
        System.err.println("end #" +i);
    }
}

Using a serializing RP makes the tasks run serially, but so does using a delay of 1msec instead of 0. It is very likely
this behavior was never intentional, but if 0 is indeed a magical value for schedule then this must be documented.
Comment 1 Jaroslav Tulach 2009-08-19 11:59:03 UTC
Long time known issue. Probably just learn to live with it. Unless Nejedlák decides to tease himself and fix it.

*** This issue has been marked as a duplicate of 40788 ***
Comment 2 Jesse Glick 2009-08-19 15:39:36 UTC
If known bugs will not be fixed, I guess I cannot trust RequestProcessor and should use java.util.concurrent.* exclusively.
Comment 3 Quality Engineering 2009-08-21 06:07:42 UTC
Integrated into 'main-golden', will be available in build *200908210201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/b92ce4c04b39
User: Jesse Glick <jglick@netbeans.org>
Log: #170581: serialize refreshes.