in Pharo, you are using a subclass ProcessLocalVariable. For instance:
"Create a class to store you variable"
ProcessLocalVariable subclass: #MyVariable.
"Use it like this"
MyVariable value: myValue.
"Inside your code, access to current value like this"
MyVariable value.
Note that even more powerful than local thread variables, you have “dynamic variables” that refer to the execution stack (more precisely than threads) you use it like this:
"Create a class to store you variable"
DynamicVariable subclass: #MyVariable.
"Use it like this"
MyVariable
value: myValue
during: [
"... execute your code here... usually a message send"
self doMyCode ].
"Inside your code, access to current value like this"
MyVariable value.
Such variables offer the same functionality (they are even more powerful) and are usually best replaced.
source
share