
- Operating System Tutorial
- OS - Home
- OS - Overview
- OS - Components
- OS - Types
- OS - Services
- OS - Properties
- OS - Processes
- OS - Process Scheduling
- OS - Scheduling algorithms
- OS - Multi-threading
- OS - Memory Management
- OS - Virtual Memory
- OS - I/O Hardware
- OS - I/O Software
- OS - File System
- OS - Security
- OS - Linux
- OS - Exams Questions with Answers
- OS - Exams Questions with Answers
- Operating System Useful Resources
- OS - Quick Guide
- OS - Useful Resources
- OS - Discussion
Thread-local storage (TLS)
Threads share the data of the process to which it belongs to. This data sharing provides one of the benefits of multithreaded programming. However, in some circumstances, each thread might need its own copy of certain data. Such data is called thread-local storage (or TLS).
For example, in a transaction-processing system, we might service each transaction in a separate thread. Each transaction might be assigned a unique identifier. To associate each thread with its unique identifier, we could use thread-local storage.
It is easy to puzzle TLS with local variables. During a single function invocation only local variables are visible, whereas TLS data are visible across function invocations. In some ways, TLS is similar to static data. The only difference is that TLS data are unique to each thread. Most thread libraries-including Windows and Pthreads-provide some form of support for thread-local storage; Java provides support as well.
- Related Articles
- Storing Credentials in Local Storage
- Difference between Session Storage and Local Storage in HTML5
- Difference between Local Storage, Session Storage, and Cookies in JavaScript
- HTML DOM Local Storage clear() method
- Trick to store credentials in local storage
- Retrieve element from local storage in JavaScript?
- Android 4.0.1 breaks WebView HTML 5 local storage?
- Checking if a key exists in HTML5 Local Storage
- HTML 5 local Storage size limit for sub domains
- Set the value in local storage and fetch – JavaScript?
- What is the difference between local storage vs cookies?
- How to store a name permanently using HTML5 Local Storage?
- How to save cache in local storage of android webview?
- How to save database in local storage of android webview?
- Build a Site Bookmark App with JavaScript by using Local Storage
