lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cédrik LIME (JIRA) <j...@apache.org>
Subject [jira] Commented: (LUCENE-2017) CloseableThreadLocal is now obsolete
Date Thu, 29 Oct 2009 19:01:59 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-2017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12771561#action_12771561
] 

Cédrik LIME commented on LUCENE-2017:
-------------------------------------

Oh, I see! The lifecyle is different, as close()'ing 1 instance of ClosableThreadLocal will
take care of all threads that have accessed it (vs only the caller thread for ThreadLocal).
This is a very subtle difference, and should be documented as such in ClosableThreadLocal
IMHO:

You only need to close() a ClosableThreadLocal instance once, whereas you need to remove()
a ThreadLocal instance from every thread that accessed that ThreadLocal instance.

That said, wouldn't we risk that one thread close() the ClosableThreadLocal when other threads
are still using it? That would invalidate currently used values!

Given that all threads supposedly follow the same code path, wouldn't a remove() be called
by each thread?

> CloseableThreadLocal is now obsolete
> ------------------------------------
>
>                 Key: LUCENE-2017
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2017
>             Project: Lucene - Java
>          Issue Type: Improvement
>    Affects Versions: 3.0
>            Reporter: Cédrik LIME
>         Attachments: CloseableThreadLocal.patch
>
>
> Since Lucene 3 depends on Java 5, we can use ThreadLocal#remove() to take care or resource
management.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


Mime
View raw message