Created
November 25, 2014 11:23
-
-
Save xjdrew/57fedd243730032a00f2 to your computer and use it in GitHub Desktop.
vs printf/std:cout bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <process.h> | |
#include <iostream> | |
void work1(void* p) | |
{ | |
while (1) { | |
printf("hello world"); | |
_sleep(1); | |
} | |
} | |
void work2(void* p) | |
{ | |
while (1) { | |
std::cout << "hello world"; | |
_sleep(1); | |
} | |
} | |
int main() | |
{ | |
for (size_t i = 0; i < 100; i++) | |
{ | |
_beginthread(work1, 0, NULL); | |
} | |
for (size_t i = 0; i < 100; i++) | |
{ | |
_beginthread(work2, 0, NULL); | |
} | |
while (1) | |
{ | |
_sleep(10000); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment