are molimporter methods threadsafe?

User 7c177bab3b

11-02-2011 15:11:34

The API docs mention molimporter being threaded. Are the methods threadsafe?


e.g. can I call readmol on the same molimporter object from multiple threads?

ChemAxon fb166edcbd

14-02-2011 15:55:17

The setThreadCount(int) method sets the number of threads used in a single MolImporter object internally, in order to process multimolecular input more efficiently.


However, MolImporter is not designed for concurrent processing from outside, ie, its inner variebles are not synchronized. Actually, multithreaded internal processing is delegated to another class and not performed directly by MolImporter itself.

User 7c177bab3b

24-02-2011 13:58:25

So I'm trying to understand how I can benefit from this through the API. Does molimporter effectively buffer the readmol calls?


I'm trying to process a very large smiles file and each computation is very fast so there would be significant benefit in threading the file read. I don't really want to split the file and run the process n times, I was looking rather to spawn n threads to do the computation using a queue.

ChemAxon fb166edcbd

24-02-2011 15:05:20

Here is a test program which calls MolImporter.setThreadCount(int) to set the number of threads.


However, it seems to me that setting the number of threads to 1 or 2 or CPU count or anything else does not make a major difference in the processing time. (I have tested this with a file of 1000000 smiles). But test it yourself.


Usage:


   java MultithreadedMolImportTest



Example:


java MultithreadedMolImportTest test.smiles 4












StephenPickett wrote:

So I'm trying to understand how I can benefit from this through the API. Does molimporter effectively buffer the readmol calls?