hey peter,
On Mon, Jan 16, 2012 at 8:45 AM, Peter K <[email protected]> wrote:
> Thanks Simon for all the explanations so far :) !

no problem!
>
>>> And what happens if two threads accessing the same ThreadState? The
>>> second will try to lock and fail and then get the minimal contended
>>> state (?) You said there is no problem when two threads accessing one
>>> ThreadState, but won't two threads accessing one
>>> DocumentsWriterPerThread make problems (e.g. when using the singleton
>>> object docState) ?
>> DocumentsWriterPerThread should never be accessed by multiple threads
>> at the same time. This is why we lock the ThreadState.
>> The maxNumThreadStates defines the max. concurrency level IW supports.
>> if more threads than threadstates enter the pool extra threads are
>> queued.
>
> queued means blocked?

yes
>
>> the problem with the min contented is that this number could change
>> while you iterate, ie. you see a state with 0 queued thread and select
>> it but while you try to lock it somebody else already locked it so it
>> might not be the min contented anymore.
>
> ok, I understand.
>
> BTW: the TODO in DocumentsWriterPerThreadPool.minContendedThreadState
> ("new Iterator per indexed doc is overkill") is easily fixable and also
> improves my stupid tests ;)
>
> for (int i = 0; i < numThreadStatesActive; i++) {
>      final ThreadState state = perThreads[i];

I will revisit this API soonish - that is one option.

simon
>
> Peter.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to