uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Howard G." <howard...@yahoo.com>
Subject Threads in UIMA
Date Tue, 30 Dec 2008 22:17:02 GMT
I have a question about threads in UIMA.  My application ("Main thread") starts an UIMA Collection
Processing Engine (CPE), which contains a Collection-Reader and several Annotators.   Here
is my code for starting the CPE:

public class UimaRunCPE extends Thread {
   * The CPE instance.
  private CollectionProcessingEngine mCPE;

    public void runCPE() throws Exception { 
    // parse CPE descriptor
    CpeDescription cpeDesc = UIMAFramework.getXMLParser().parseCpeDescription(
            new XMLInputSource(pathToDescriptor));

    // instantiate CPE
    mCPE = UIMAFramework.produceCollectionProcessingEngine(cpeDesc);

    // Create and register a Status Callback Listener
    mCPE.addStatusCallbackListener(new StatusCallbackListenerImpl());

    // Start Processing
    System.out.println("CPE ended\n");

As I understand it (I stepped thru it in debug-mode in Eclipse), the CPE works like this -
1.  all the Annotator.initialize()'s  are done in "Main thread"

2. when mCPE.process() is called,  these threads are created---
	CPMEngine Thread
	Processing Pipeline#1 Thread
3. the Collection-Reader runs in its own thread

4. the Annotator.process() methods run in the Processing Pipeline#1 Thread

5. when all Annotators are done, Processing Pipeline#1 Thread and CPMEngine Thread go away.
 Control goes to BaseCPMImpl-Thread.collectionProcessComplete().  When that's done, all processing
is over.  

My problem is this:  in Main-thread, mCPE.process() returns right away; it does not wait around
to make sure that the CPE finished OK.  I need a way to do that.  It would work if Main-thread
could do a join() on BaseCPMImpl-Thread, but I don't see any way to do that.

Any ideas?

View raw message