[concurrency-interest] Whats up with the ThreadPoolExecutor?

Ravinder Singh ravs at online.no
Tue Aug 23 03:27:23 EDT 2005


I take it back... sorry.. It does offcourse affect the value, if you 
don't sync it.


Ravinder Singh wrote:

> I don't think its suspect, since the integer is only incremented and 
> never deccremented, the value should allways be correct.
>
> I have now corrected to use a separate Runnable for each task.
>
>>>   static private int cSt, cWrk;
>>>
>>>   public static class Woerker implements Runnable
>>>   {
>>>       public void run()
>>>       {
>>>           cSt++;
>>>       }
>>>   }
>>
>>
>>
>> This is not the main problem, but you are incrementing the cSt 
>> counter without any kind of synchronization, so the cSt value you are 
>> seeing is suspect.
>>
>> --tim
>>
>
>
>
>



More information about the Concurrency-interest mailing list