Thanks Simon for all the explanations so far :) !

>> 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?

> 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];

Peter.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to