Thread DataSlot

  • Thread starter Thread starter b.fokke
  • Start date Start date
B

b.fokke

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
 
The difference is in the "thread specific data" ... By wrapping your
thread in class you do not have "thread specific data".

Regards,
Tasos
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top