Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.0 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. _declspec(thread) DWORD Id;
  5. VOID
  6. TestThread(
  7. LPVOID ThreadParameter
  8. )
  9. {
  10. DWORD st;
  11. Id = GetCurrentThreadId();
  12. printf(" TEST THREAD Id = %d vs %d\n",Id,GetCurrentThreadId());
  13. Sleep(1000);
  14. printf(" TEST THREAD Id = %d vs %d\n",Id,GetCurrentThreadId());
  15. ExitThread(0);
  16. }
  17. int __cdecl
  18. main(
  19. int argc,
  20. char *argv[],
  21. char *envp[]
  22. )
  23. {
  24. HANDLE Thread;
  25. DWORD ThreadId;
  26. int i;
  27. Id = GetCurrentThreadId();
  28. printf("MAIN THREAD Id = %d vs %d\n",Id,GetCurrentThreadId());
  29. for(i=0;i<10;i++) {
  30. Thread = CreateThread(NULL,0L,(PVOID)TestThread,(LPVOID)99,0,&ThreadId);
  31. if ( !Thread ) {
  32. printf("Thread creation failed %d\n",GetLastError());
  33. }
  34. WaitForSingleObject(Thread,INFINITE);
  35. CloseHandle(Thread);
  36. printf("\nMAIN THREAD Id = %d vs %d\n",Id,GetCurrentThreadId());
  37. }
  38. return 1;
  39. }