NullPointerException after removing all tasks from ThreadPoolExecutor

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

NullPointerException after removing all tasks from ThreadPoolExecutor

Norman Elton-2
I've setup a simple test scenario that is producing a  
NullPointerException. My code is...

----------------
ThreadPoolExecutor tpe = new ThreadPoolExecutor(1, 1, 5,  
TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new  
JobThreadFactory());

tThread t1 = new tThread(1);
tThread t2 = new tThread(2);
tThread t3 = new tThread(3);

tpe.execute(t1);
tpe.execute(t2);

tpe.remove(t2);

tpe.execute(t3);
----------------

The "tThread" class merely waits five seconds and produces a simple  
message to System.out. No magic there. The code runs the first thread  
(t1) as expected, then starts spewing out exceptions of the form...

Exception in thread "EX-1737" java.lang.NullPointerException
         at java.util.concurrent.LinkedBlockingQueue.extract(Unknown  
Source)
         at java.util.concurrent.LinkedBlockingQueue.take(Unknown  
Source)
         at java.util.concurrent.ThreadPoolExecutor.getTask(Unknown  
Source)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run
(Unknown Source)
         at java.lang.Thread.run(Unknown Source)

It does not appear to like it when I remove all the tasks from the  
queue. If I leave one task on the queue, it remains happy.

Any ideas? I looked through the JSR166 bugs, and did not find  
anything that looked promising.

Thanks for your help,

Norman
_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: NullPointerException after removing all tasks from ThreadPoolExecutor

Doug Lea

> Any ideas? I looked through the JSR166 bugs, and did not find  
> anything that looked promising.
>

I'm pretty sure this is:
   http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6215625

Sorry that it takes so long to get these into Sun Tiger update releases.

In the mean time, you can grab source from our CVS, compile, and
place in your -Xbootclasspath.

-Doug

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest