Questions tagged [thread-confinement]

3 questions
973
votes
26 answers

When and how should I use a ThreadLocal variable?

When should I use a ThreadLocal variable? How is it used?
45
votes
8 answers

Thread Confinement

I am reading Java Concurrency in Practice and kind of confused with the thread confinement concept. The book says that When an object is confined to a thread, such usage is automatically thread-safe even if the confined object itself is not So…
denniss
  • 17,229
  • 26
  • 92
  • 141
0
votes
1 answer

Is there a elegant way to confine a class to a thread?

I have a class which I want to confine to a thread. To be precise I want it's void returning methods to be accessed on a certain thread or serial queue created by the class privately. To acheive this I looked at the NSManagedObjectContext API as a…
Rohan Bhale
  • 1,323
  • 1
  • 11
  • 29