User dfeb81947d
21-06-2011 12:46:35
Dear support,
I wonder how JChemSearch deals with multithreading? I tryed two methods: read SD File and for each molecule make a structure search.
First Method I call the search within a thread, for exemple if all structure are loaded on a Map.
I tried also using AWT thread (SwingUtilities.invokeAndWait(Runnable))
for(Entry<Integer, String> entry : map.entrySet()) {
final String molfile = entry.getValue();
new Thread(new Runnable() {
@Override
public void run() {
// get new Connection from Pool and initialize ConnectionHandler
JChemSearch searcher = new JChemSearch();
searcher.setConnectionHandler(connectionHandler);
searcher.setStructureTable(csmolTable);
searcher.setResultTableMode(JChemSearch.NO_RESULT_TABLE);
searcher.setInfoToStdError(false);
searcher.setRunMode(JChemSearch.RUN_MODE_SYNCH_COMPLETE);
searcher.setQueryStructure(molfile);
searcher.setSearchOptions(searchOptions);
try {
searcher.run();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
The other solution is to do each search following each others (the following code is also an example)
for(Entry<Integer, String> entry : map.entrySet()) {
final String molfile = entry.getValue();
// get new Connection from Pool and initialize ConnectionHandler
JChemSearch searcher = new JChemSearch();
searcher.setConnectionHandler(connectionHandler);
searcher.setStructureTable(csmolTable);
searcher.setResultTableMode(JChemSearch.NO_RESULT_TABLE);
searcher.setInfoToStdError(false);
searcher.setRunMode(JChemSearch.RUN_MODE_SYNCH_COMPLETE);
searcher.setQueryStructure(molfile);
searcher.setSearchOptions(searchOptions);
try {
searcher.run();
} catch (Exception e) {
e.printStackTrace();
}
}
I use a set of 100 molécules to be searched on a database containing 800 000 structures.
I tried substructure search and similarity search on the following method: do a blank search to load all structure in cache, search for 100 structures with multi-threading, when it's over calculate time. search for 100 structures in single thread.
It appears that multi-threading search is not faster, sometimes even slower than the sequential search.
How do JChemSearch on API manage structure search when multi-threading access?
I'm using JChem 5.2.6 with jdk 1.6 on oracle 10g
Thank you very much for your hints and explanations.
Best Regards,
Jacques