Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #14824

Proposed new Java feature

Path csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From "Mike Schilling" <mscottschilling@hotmail.com>
Newsgroups comp.lang.java.programmer
Subject Proposed new Java feature
Date Sat, 26 May 2012 16:11:13 -0700
Organization A noiseless patient Spider
Lines 23
Message-ID <jprnu7$uv8$1@dont-email.me> (permalink)
Injection-Date Sat, 26 May 2012 23:11:03 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="MPGXQTXsvPvqVKHgwEYAAw"; logging-data="31720"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+llV8JlRyvqPjvHop5/BFjMtACTxyFEAY="
X-MimeOLE Produced By Microsoft MimeOLE V6.00.2900.6157
X-RFC2646 Format=Flowed; Original
X-Newsreader Microsoft Outlook Express 6.00.2900.5931
Cancel-Lock sha1:kdSc/6zG9MMhLkdkHNzoTJKkaHQ=
X-Priority 3
X-MSMail-Priority Normal
Xref csiph.com comp.lang.java.programmer:14824

Show key headers only | View raw


First a few observations:

1. ThreadLocals may be, in general, an abomination, but there are situation 
where they're the least of evils.  And if you're building a framework in 
which third-party code runs (e.g. a webserver), there's no way to disallow 
their use.

2. ThreadLocals interact badly with ThreadPools, because the ThreadLocals 
keep their value when the tyhread is put back into the pool.  This can lead 
to leaks and even potential security issues.

3. The current implementation of ThreadLocal is this: each thread contains a 
map from the ThreadLocal instance to its value for that thread.  (This is 
slightly less intiutive than giving a ThreadLocal instance a map from Thread 
to value, but has the advantage that the map, which is only used within one 
thread, needn't be synchronized.)

Proposed feature: a static method on Thread that clears all ThreadLocals for 
the current thread.  By 3 it's trivial to implement.  By 1 and 2 it's 
needed.  And ThreadPool implementations can simply call it directly before 
putting the Thread back into the pool.

Back to comp.lang.java.programmer | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Proposed new Java feature "Mike Schilling" <mscottschilling@hotmail.com> - 2012-05-26 16:11 -0700
  Re: Proposed new Java feature Robert Klemme <shortcutter@googlemail.com> - 2012-05-27 13:32 +0200
    Re: Proposed new Java feature "Mike Schilling" <mscottschilling@hotmail.com> - 2012-05-27 11:14 -0700
      Re: Proposed new Java feature Robert Klemme <shortcutter@googlemail.com> - 2012-05-28 12:13 +0200
      Re: Proposed new Java feature v_borchert@despammed.com (Volker Borchert) - 2012-06-04 20:16 +0000
  Re: Proposed new Java feature markspace <-@.> - 2012-05-27 09:28 -0700
    Re: Proposed new Java feature "Mike Schilling" <mscottschilling@hotmail.com> - 2012-05-27 11:00 -0700
      Re: Proposed new Java feature Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-05-27 11:46 -0700
        Re: Proposed new Java feature "Mike Schilling" <mscottschilling@hotmail.com> - 2012-05-27 12:04 -0700
          Re: Proposed new Java feature Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-05-27 15:30 -0400
            Re: Proposed new Java feature "Mike Schilling" <mscottschilling@hotmail.com> - 2012-05-27 12:59 -0700
              Re: Proposed new Java feature Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-05-27 17:51 -0400
                Re: Proposed new Java feature markspace <-@.> - 2012-05-27 15:20 -0700
                Re: Proposed new Java feature Robert Klemme <shortcutter@googlemail.com> - 2012-05-28 12:13 +0200
                Re: Proposed new Java feature markspace <-@.> - 2012-05-28 08:28 -0700
                Re: Proposed new Java feature Robert Klemme <shortcutter@googlemail.com> - 2012-05-28 19:29 +0200
                Re: Proposed new Java feature markspace <-@.> - 2012-05-28 12:16 -0700
                Re: Proposed new Java feature Robert Klemme <shortcutter@googlemail.com> - 2012-05-28 22:58 +0200
                Re: Proposed new Java feature "Mike Schilling" <mscottschilling@hotmail.com> - 2012-05-28 21:40 -0700
                Re: Proposed new Java feature Robert Klemme <shortcutter@googlemail.com> - 2012-05-29 22:52 +0200
                Re: Proposed new Java feature "Mike Schilling" <mscottschilling@hotmail.com> - 2012-05-29 18:53 -0700
                Re: Proposed new Java feature Tom Anderson <twic@urchin.earth.li> - 2012-05-27 23:27 +0100
                Re: Proposed new Java feature Robert Klemme <shortcutter@googlemail.com> - 2012-05-28 12:22 +0200
                Re: Proposed new Java feature "Mike Schilling" <mscottschilling@hotmail.com> - 2012-05-27 21:43 -0700
                Re: Proposed new Java feature Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-05-29 14:32 +0000
  Re: Proposed new Java feature Tom Anderson <twic@urchin.earth.li> - 2012-05-27 18:43 +0100
  Re: Proposed new Java feature Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2012-06-02 12:41 -0700
    Re: Proposed new Java feature markspace <-@.> - 2012-06-02 15:55 -0700

csiph-web