[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

Sent by: concurrency-interest-admin@cs.oswego.edu
13.02.2004 14:12

        To:     <concurrency-interest@altair.cs.oswego.edu>
        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

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?

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() {

Thanks a lot

Matthias Ernst
CoreMedia - The Content Technology Experts

"Toll takes its time."

Concurrency-interest mailing list