[concurrency-interest] Tiger 1.5 beta 1: ThreadPoolExecutor uses 100% CPU

Dmitry Kiriy dmitry.kiriy@db.com
Fri, 13 Feb 2004 14:44:29 +0300


Just put at the end System.exit(0);
________________________________
Dmitriy Kiriy

Derivatives IT Dept.
Global Markets,
Deutsche Bank Moscow

Ph.: +7 095 7830367
Ph. local: 1367




<matthias.ernst@coremedia.com>
Sent by: concurrency-interest-admin@cs.oswego.edu
13.02.2004 14:12

 
        To:     <concurrency-interest@altair.cs.oswego.edu>
        cc: 
        Subject:        [concurrency-interest] Tiger 1.5 beta 1: ThreadPoolExecutor uses 100% CPU


Sorry to bother you here but would anybody try to run the attached
testcase on a win xp machine ?

On my machine (XP SP 2, 1 CPU), running with

  java ThreadPool 10

it will consume 100% CPU after finishing work when actually it should be
idle.


I filed a Bug with Sun but they don't seem able (enough?) to reproduce it.
Can anyone confirm before I go through this !@#!@# report procedure again?
http://developer.java.sun.com/developer/bugParade/bugs/4990885.html


import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicInteger;

public class ThreadPool {
  public static void main(String[] args) {
    int n = Integer.parseInt(args[0]);
    final AtomicInteger todo = new AtomicInteger(2*n);

    ExecutorService p = Executors.newFixedThreadPool(n);
    for(int i=0; i<2*n; i++) {
      p.execute(new Runnable() { public void run() {
                 System.out.println(todo.decrementAndGet());
      }});
    }
  }
}


Thanks a lot
Matthias

-- 
Matthias Ernst
CoreMedia - The Content Technology Experts

"Toll takes its time."

_______________________________________________
Concurrency-interest mailing list
Concurrency-interest@altair.cs.oswego.edu
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest