You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Swril <lr...@gmail.com> on 2014/04/01 13:05:29 UTC

Threadsafe advice for using SharedResourceObject

I have an AE that I am running in a CPE. 
The AE has a ExternalResource to a SharedResourceObject.
I set the setMaxProcessingUnitThreadCount to 5.

When I run the pipeline, I am getting errors like NPE which hinted that 
things are out-of-step due to the multiple threads.

Are there any advice on what to do for using AE with ExternalResource in a 
CPE?


Re: Threadsafe advice for using SharedResourceObject

Posted by Swril <lr...@gmail.com>.
Richard Eckart de Castilho <re...@...> writes:

> 
> I assume you are talking about runtime, not initialization time.
> 
> At runtime, it is convenient if the shared object has no mutable
> state. If it has, you might want to wrap that in as ThreadLocal
> variable.
> 
> If there is a problem during initialization, that would be a bug
> I suppose.
> 


Thanks for your answers.

Yes I was talking about runtime.
We found that the sharedresource was using instance variable and have changed 
it to local variable. It runs ok now.


Re: Threadsafe advice for using SharedResourceObject

Posted by Richard Eckart de Castilho <re...@apache.org>.
I assume you are talking about runtime, not initialization time.

At runtime, it is convenient if the shared object has no mutable
state. If it has, you might want to wrap that in as ThreadLocal
variable.

If there is a problem during initialization, that would be a bug
I suppose.

-- Richard

On 01.04.2014, at 14:05, Marshall Schor <ms...@schor.com> wrote:

> On 4/1/2014 7:05 AM, Swril wrote:
>> I have an AE that I am running in a CPE. 
>> The AE has a ExternalResource to a SharedResourceObject.
>> I set the setMaxProcessingUnitThreadCount to 5.
>> 
>> When I run the pipeline, I am getting errors like NPE which hinted that 
>> things are out-of-step due to the multiple threads.
>> 
>> Are there any advice on what to do for using AE with ExternalResource in a 
>> CPE?
> 
> One thought: it's probably necessary to write the code you supply for the
> SharedResourceObject to be thread safe.  A good source for understanding the
> complex details around how to do this is
> http://lmgtfy.com/?q=java+concurrency+in+practice  .
> -Marshall

Re: Threadsafe advice for using SharedResourceObject

Posted by Marshall Schor <ms...@schor.com>.
On 4/1/2014 7:05 AM, Swril wrote:
> I have an AE that I am running in a CPE. 
> The AE has a ExternalResource to a SharedResourceObject.
> I set the setMaxProcessingUnitThreadCount to 5.
>
> When I run the pipeline, I am getting errors like NPE which hinted that 
> things are out-of-step due to the multiple threads.
>
> Are there any advice on what to do for using AE with ExternalResource in a 
> CPE?

One thought: it's probably necessary to write the code you supply for the
SharedResourceObject to be thread safe.  A good source for understanding the
complex details around how to do this is
http://lmgtfy.com/?q=java+concurrency+in+practice  .
-Marshall
>
>
>