DmitryKey / simplenlg

Automatically exported from code.google.com/p/simplenlg
1 stars 0 forks source link

Thread-safe NIH Lexicon access in the NIHDBLexicon class #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Purpose of code changes on this branch:

Testing has shown that HyperSQL DB queries using the Java API of LexAccess are 
not thread safe. You can't start one query when there is another running in a 
different thread. It crashes.

All queries to the NIH lexicon are done though the NIHDBLexicon class. With 
this change to the NIHDBLexicon class, a multi-threaded application using a 
singleton NIHDBLexicon object can safely query the HSQLDB.

In the future, this should not be necessary. The latest release, 2.2 of HSQLDB 
claims to be "fully-multithreaded". This was released in May 2011. This 
confirms my experience that earlier versions are not multi-threaded. It is not 
simply a LexAccess issue.

But until this version is integrated into the LexAccess DB release, 
NIHDBLexicon calls need to be synchronized.

Assuming the use of a single Lexicon object in a multi-threaded application, 
synchronizing the three methods of NIHDBLexicon that use the LexAccess api do a 
HSQLDB query should provide thread-safety.

After the review, I'll merge this branch into:
/trunk

Original issue reported on code.google.com by ChristopherCHowell@gmail.com on 26 May 2011 at 3:24

GoogleCodeExporter commented 9 years ago
The only file to review is NIHDBLexicon.java

Original comment by ChristopherCHowell@gmail.com on 26 May 2011 at 3:27

GoogleCodeExporter commented 9 years ago
Verified that the thread-safe methods work; introduced tests in the NIHLexicon 
test suite.

Original comment by bertug...@gmail.com on 7 Jun 2011 at 8:16