Syntax
#include <stdlib.h> void *_threadstore(void);Description
You can only use _threadstore in multithread programs.
This example uses _threadstore to point to storage that is local to the thread. It prints the address pointed to by _threadstore.
#include <stdlib.h>
#include <stdio.h>
#define privateStore (*_threadstore())
void thread(void *dummy)
{
privateStore = malloc(100);
printf("The starting address of the storage space is %p\n", privateStore);
/* user must free storage before exiting thread */
free (privateStore);
_endthread();
}
int main(void)
{
int i;
for (i = 0; i < 10; i++)
_beginthread(thread, NULL, (unsigned) 32096, NULL);
DosSleep(5000L);
return 0;
}
Related Information