threadpuddle

ThreadPuddle: a fixed-size thread pool.

See:
          Description

Packages
com.msi.threadpuddle  

 

ThreadPuddle: a fixed-size thread pool.

Author:
Ken Thompson
Copyright © 2001-2002 MileStone Solutions, Inc. (MSI).
All Rights Reserved.

MSI's Thread Puddle is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

MSI's Thread Puddle is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with MSI's Thread Puddle; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Overview

A simple example (MyPuddle.java):

import com.msi.threadpuddle.ThreadPuddleImpl;
import com.msi.threadpuddle.ThreadPuddle;
import com.msi.threadpuddle.State;
import java.util.Properties;

public class MyPuddle {
  private ThreadPuddle threadPuddle = null;

  public MyPuddle() {
    Properties prop = new Properties();
    prop.setProperty("threadCount", "10");
    prop.setProperty("debug", "true");
    try {
        threadPuddle = new ThreadPuddleImpl(prop);
    } catch (Exception e) {
      System.err.println("unable to create thread pool");
      System.exit(-1);
    }
  }

  public void addAJob() {
    Runnable Job = new MyJob();	// implements Runnable
    threadPuddle.addJob(Job);
  }

}

This creates a thread puddle with 10 (and only 10) threads in the constructor and provides a method for adding a job to the puddle job queue.

Related Documentation



Copyright © 2001-2002 MileStone Solutions, Inc. All Rights Reserved.