• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

ThreadLocal

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, all
does anyone know how to use ThreadLocal && InheritableThreadLocal?
and function of these class (i have read it in j2ee implementation source)

thanks
michael
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

quote (from API SPec):

public class ThreadLocal
extends Object
This class provides ThreadLocal variables. These variables differ from their normal counterparts in that
each thread that accesses one (via its get or set method) has its own, independently initialized copy of
the variable. ThreadLocal objects are typically private static variables in classes that wish to associate
state with a thread (e.g., a user ID or Transaction ID).
Each thread holds an implicit reference to its copy of a ThreadLocal as long as the thread is alive and
the ThreadLocal object is accessible; after a thread goes away, all of its copies of ThreadLocal
variables are subject to garbage collection (unless other references to these copies exist).

hth.
- satya

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got the concept. Do you have any examples in the Ranch to understand how to use ThreadLocal? or any links?
 
michael huang
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
spec i have read, but i need some explanation.

michael
 
Do you pee on your compost? Does this tiny ad?
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic