Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does thread-local mean thread safe?

Specifically I'm talking about Python. I'm trying to hack something (just a little) by seeing an object's value without ever passing it in, and I'm wondering if it is thread safe to use thread local to do that. Also, how do you even go about doing such a thing?

like image 957
orokusaki Avatar asked Sep 25 '10 17:09

orokusaki


1 Answers

No -- thread local means that each thread gets its own copy of that variable. Using it is (at least normally) thread-safe, simply because each thread uses its own variable, separate from variables by the same name that's accessible to other threads. OTOH, they're not (normally) useful for communication between threads.

like image 180
Jerry Coffin Avatar answered Sep 30 '22 01:09

Jerry Coffin