Bram,
The members of a class can be accessed by any thread. Encapsulating a
running thread in a class doesn't prevent other threads from accessing
the members of that class. Of course you could provide a loose
enforcement by simply making sure you don't access that class from
another thread. Contrast that with thread local storage which strictly
enforces the coupling of data to a specific thread. There may be cases
where you want multiple threads executing code in the same class, but
have their own copy of data to work with.
Brian
b.*****@gmail.com wrote:
The Thread class exposes AllocateNamedDataSlot() and AllocateDataSlot()
methods which allow allocating memory for thread-specific data. How is
this different from encapsulating each running thread in a class and
using that class to store the data?
Bram Fokke
Utrecht, the Netherlands