Chapter 8. TSD
Thread-Specific Data
Java TSD
APIs Used in this Chapter
The Class java.lang.ThreadLocal
In which explanations of thread-specific data, their use, and some implementation details are provided.
Thread-Specific Data
Sometimes it is useful to have data that is globally accessible to any function, yet still unique to the thread. Two threads that are printing out data, one in French and the other in Danish, would find it most convenient to have a private global variable, which they could set to the desired language. Any function at any depth could then access this variable without the hassle of passing it at every call.
TSD provides this kind of global data by means of a set of function calls. The techniques used by POSIX and Java provide the ...
Get Multithreaded Programming with JAVA™ Technology now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.