org.knime.base.node.mine.decisiontree2.learner
Class ParallelProcessing

java.lang.Object
  extended by org.knime.base.node.mine.decisiontree2.learner.ParallelProcessing

public class ParallelProcessing
extends Object

Holds information for the parallel processing and is also used for synchronization stuff.

Author:
Christoph Sieb, University of Konstanz

Constructor Summary
ParallelProcessing(int numberThreads)
          Constructor.
 
Method Summary
 void decrementNumThreads()
          Decrements the current number of threads in use by 1.
 int getCurrentThreadsInUse()
          Returns the number of threads currently in use.
 int getMaxNumberThreads()
           
 void incrementNumThreads()
          Increments the current number of threads in use by 1.
 boolean isThreadAvailable()
          Method invoked to manage available thread capacity.
 void isThreadAvailableBlocking()
          Method invoked to manage available thread capacity.
 void reset()
          Sets the number of current threads to 1.
 void setNumberThreads(int numberThreads)
          Sets the number of parallel threads to use.
 void threadTaskFinished()
          Once a thread which synchronizes on this object has finished, it must invoke this method to allow other threads to continue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParallelProcessing

public ParallelProcessing(int numberThreads)
Constructor.

Parameters:
numberThreads - the number of threads to use at most in parallel
Method Detail

setNumberThreads

public void setNumberThreads(int numberThreads)
Sets the number of parallel threads to use.

Parameters:
numberThreads - the number of threads to use in parallel

getCurrentThreadsInUse

public int getCurrentThreadsInUse()
Returns the number of threads currently in use.

Returns:
the number of threads currently in use

incrementNumThreads

public void incrementNumThreads()
Increments the current number of threads in use by 1.


decrementNumThreads

public void decrementNumThreads()
Decrements the current number of threads in use by 1.


isThreadAvailableBlocking

public void isThreadAvailableBlocking()
Method invoked to manage available thread capacity. In case there are not enough threads the invocation waits until a thread gets free.


isThreadAvailable

public boolean isThreadAvailable()
Method invoked to manage available thread capacity. Returns true if there was an available thread. Note: invoking this method and getting true causes the thread counter to be incremented!! Non blocking!!

Returns:
whether a thread is available

threadTaskFinished

public void threadTaskFinished()
Once a thread which synchronizes on this object has finished, it must invoke this method to allow other threads to continue.


getMaxNumberThreads

public int getMaxNumberThreads()
Returns:
the maxNumberThreads

reset

public void reset()
Sets the number of current threads to 1. Necessary if for example the execution was canceled and the threads could not finish and decrement the counter.



Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.