[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to store static data in a multi-thread program?



Previously Russell Coker wrote:
> Have a global variable of type "int *", before spawning threads malloc enough 
> memory for an int per thread and have the global variable point to it.  Then 
> have each thread know it's number (in some suitable way) and use that index 
> into the array.

Or search for thread local storage in the pthread docs which is probably
a better approach.

Wichert.

-- 
  _________________________________________________________________
 /wichert@wiggy.net         This space intentionally left occupied \
| wichert@deephackmode.org            http://www.liacs.nl/~wichert/ |
| 1024D/2FA3BC2D 576E 100B 518D 2F16 36B0  2805 3CB8 9250 2FA3 BC2D |



Reply to: