Concurrent plugin API usage examples

ChemAxon's concurrent framework is based on the Java 5.0 java.util.concurrent API.

There are three examples which show code samples making use of ChemAxon's concurrent framework. The common code is written in ConcurrentPluginApplication: it starts a ConcurrentProcessor with a specified InputProducer and WorkUnitFactory. The InputProducer is supposed to produce the plugin inputs: the input molecules and possibly the plugin objects which perform the calculation. The WorkUnit objects produced by the WorkUnitFactory are run concurrently by the ConcurrentProcessor and supposed to execute the plugin calculation (the CalculatorPlugin.run() method). Finally, the results are collected in ConcurrentPluginApplication.consume(Object result) in the main thread. It is important to process the results in a single thread so that the order of the results was the same as the order of the input molecules.

Our examples show different ways to provide the inputs and outputs for the concurrent processor. Input molecules are read from System.in if the molecule file is omitted.
The following API is used:

In the following examples we use the test.smiles input molecule file:

The above examples can also be run by run.sh (Linux/UNIX) or RUN.BAT (Windows).