this repo has no description
1#include <stdio.h>
2#include <pthread.h>
3
4void* printThread(void* v);
5
6struct SimpleStruct
7{
8 SimpleStruct();
9 ~SimpleStruct();
10
11 int val;
12};
13
14__thread static SimpleStruct var;
15
16int main()
17{
18 printf("main: var = %d\n", var.val);
19 var.val = 321;
20 printf("main: var = %d\n", var.val);
21
22 pthread_t pth;
23 pthread_create(&pth, NULL, printThread, NULL);
24 pthread_join(pth, NULL);
25
26 return 0;
27}
28
29SimpleStruct::SimpleStruct()
30{
31 puts("Constructor called");
32 val = 123;
33}
34
35SimpleStruct::~SimpleStruct()
36{
37 puts("Destructor called");
38}
39
40void* printThread(void* v)
41{
42 printf("thread: var = %d <- this seems to be broken on all platforms\n", var.val);
43 return NULL;
44}
45