Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- void threadrun(string threadname) {
- for (int i = 0; i < 10; i++) {
- cout << threadname << " " << i << endl;
- i++;
- }
- }
- void threadrun2(string threadname2) {
- for (int i = 1; i < 10; i++) {
- cout << threadname2 << " " << i << endl;
- i++;
- }
- }
- int main() {
- setlocale(LC_ALL, "rus");
- srand(time(NULL));
- thread threadA(threadrun, "threadA");
- thread threadB(threadrun, "threadB");
- thread threadC(threadrun2, "threadC");
- thread threadD(threadrun2, "threadD");
- threadA.join();
- threadB.join();
- threadC.join();
- threadD.join();
- return 0;
- }
Add Comment
Please, Sign In to add comment