On Nov 26, 2007 8:15 PM, Mark Phippard <markphip@gmail.com> wrote:
> <dlr> Have you used Java's ThreadLocal class before?
> <markphip> no
> <dlr> It can be used to achieve almost "magical" behavior.
> <dlr> It's really easy to mis-use, too, and results in code that's
> harder for newcomers to follow.
> <dlr> But for the original author, it's quite easy to use.
> <dlr> Basically, it gives you a hashtable that's associated with the
> "current" thread (whichever that may be).
> <dlr> So when you call SVNClient.setProgressListener(), it would in
> turn call ThreadLocal.set().
> <dlr> ...associating the supplied ProgressListener with the current thread.
I read this article about ThreadLocal:
http://www-128.ibm.com/developerworks/java/library/j-threads3.html
I do not see how it would fix this problem. It would let me have a
separate ProgressListener on each thread, but the problem was that
there is just a single SVNClient, so there would still be a problem of
calling SVNClient.setProgressListener(null) on another thread.
Actually, my current code would be creating a unique ProgressListener
per thread anyway.
I could see where using ThreadLocal to create one SVNClient per thread
could work (I am a little concerned about performance based on that
article though). It probably is not an issue in a desktop app like
Eclipse though. A problem with this approach is that I do not see how
I could call dispose(). I could use finalize() and that might be OK,
but most text books do not encourage its use. I cannot think of
another way to call dispose() though.
--
Thanks
Mark Phippard
http://markphip.blogspot.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Nov 27 04:23:31 2007