You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by "Howard G." <ho...@yahoo.com> on 2008/12/30 23:17:02 UTC
Threads in UIMA
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
mCPE.process();
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---
BaseCPMImpl-Thread
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?
Re: Threads in UIMA
Posted by "Howard G." <ho...@yahoo.com>.
Sounds good, I'll try it -- Thanks!
--- On Tue, 12/30/08, Adam Lally <al...@alum.rpi.edu> wrote:
> From: Adam Lally <al...@alum.rpi.edu>
> Subject: Re: Threads in UIMA
> To: uima-user@incubator.apache.org, howardg22@yahoo.com
> Date: Tuesday, December 30, 2008, 5:57 PM
> On Tue, Dec 30, 2008 at 5:17 PM, Howard G.
> <ho...@yahoo.com> wrote:
> > 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?
> >
>
> Hi Howard,
>
> You can do this by waiting for the the
> StatusCallbackListener's
> collectionProcessComplete() method to be called. For
> example the main
> thread could call wait() on the StatusCallbackListenerImpl
> instance,
> and then
> StatusCallbackListenerImpl.collectionProcessComplete() can
> call notifyAll.
>
> -Adam
Re: Threads in UIMA
Posted by Adam Lally <al...@alum.rpi.edu>.
On Tue, Dec 30, 2008 at 5:17 PM, Howard G. <ho...@yahoo.com> wrote:
> 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?
>
Hi Howard,
You can do this by waiting for the the StatusCallbackListener's
collectionProcessComplete() method to be called. For example the main
thread could call wait() on the StatusCallbackListenerImpl instance,
and then StatusCallbackListenerImpl.collectionProcessComplete() can
call notifyAll.
-Adam