KNIME node multithreading

Hi

I stumbled accross the 'ThreadedColAppenderNodeModel' while looking at a CDK node.

I updated oned of my nodes to run using this node model instead. The node runs (much faster :)) and I would like to let a user choose the number of theads to run. 

KNIME has a global max number of threads, how do I get this value so I can make sure that a user can't set a value higher than the max possible?

Edit: This may be a nonsense question as all I can do is set the max number of threads anyway so I guess this is handled for me. 

Cheers

Sam

(disclaimer: I'm no official KNIMEr, so maybe you will get a better, more "official" answer).

Here's how I'm doing it in our nodes:

AbstractCellFactory factory = new AbstractCellFactory(specs) {
    @Override
    public DataCell[] getCells(DataRow row) {
        // ...
    }
factory.setParallelProcessing(true, numberOfThreads, 
           /* max. queue size */ 50);

See: AbstractCellFactory

qqilihq is refers to using the ColumnRearranger which is the preferred method if you are "just" adding additional column in your node. In his example you can see how to use multithreading with the ColumnRearranger.

Thanks both. 

My question was more along the lines of what happens if I set the number of threads to greater than the max number of theads allowed.

I used the method:

Open Declaration

"void org.knime.core.util.ThreadPool.setMaxThreads(int newValue)

Sets the maximum number of threads in the pool. If the new value is smaller than the old value running surplus threads will not be interrupted. If the new value is bigger than the old one, waiting jobs will be started immediately."

Lets say I pass in the value 20. If my KNIME preferences says "Maximum working threads for all nodes: 10", will it only be able to use 10 threads?

I will update the node to use the preffered method you have provided :).

Cheers

Sam

 

It depends... If you the the value on the global thread pool it will override the values from the preferences. If you set the value on a sub pool, the maximum is still determined by the global values.