1 thread-specific storage (tss) storage/space (a variable) per thread. –a variable is associated...

of 22/22
1 Thread-specific Storage Thread-specific Storage (TSS) (TSS) • Storage/space (a variable) per thread. – A variable is associated with a thread. – The per-thread variable is never touched by other threads • java.lang.ThreadLocal

Post on 22-Dec-2015

218 views

Category:

Documents

4 download

Embed Size (px)

TRANSCRIPT

  • Slide 1
  • 1 Thread-specific Storage (TSS) Storage/space (a variable) per thread. A variable is associated with a thread. The per-thread variable is never touched by other threads java.lang.ThreadLocal
  • Slide 2
  • 2 Imagine this Scenario Different threads generate different data store them in a result holder read them from the result holder. Need to protect the result holder from threads. A read-write lock to be implemented in the holder. Result holder Thread 1 Thread 1s result Thread 2s result Thread 2 Thread 3
  • Slide 3
  • 3 When does a TSS Work? If each element is paired with a thread and accessed only by the thread TSS works well. Easier-to-read code Safer code Result holder Thread 1 Thread 1s result Thread 2s result Thread 2 Thread 3