diff --git a/hello/hello-tls.c b/hello/hello-tls.c index 40d38c0..8cb516c 100644 --- a/hello/hello-tls.c +++ b/hello/hello-tls.c @@ -10,26 +10,26 @@ static __thread int tlsvar = 1; static unsigned __stdcall threadfunc(void* arg) { int id = (int)arg; - printf("thread %d, tlsvar %p %d\n", id, &tlsvar, tlsvar); + printf("thread %d, tlsvar %p initially %d\n", id, &tlsvar, tlsvar); tlsvar = id + 100; - for (int i = 0; i < 5; i++) { + for (int i = 0; i < 4; i++) { printf("thread %d, tlsvar %p %d\n", id, &tlsvar, tlsvar); tlsvar += 10; - Sleep(1000); + Sleep(500); } return 0; } int main(int argc, char* argv[]) { - HANDLE threads[5]; + HANDLE threads[3]; - for (int i = 0; i < 5; i++) { + for (int i = 0; i < 3; i++) { printf("mainthread, tlsvar %p %d\n", &tlsvar, tlsvar); tlsvar += 10; threads[i] = (HANDLE)_beginthreadex(NULL, 0, threadfunc, (void*)(intptr_t) (i + 1), 0, NULL); - Sleep(750); + Sleep(350); } - for (int i = 0; i < 5; i++) { + for (int i = 0; i < 3; i++) { WaitForSingleObject(threads[i], INFINITE); CloseHandle(threads[i]); }