Gistrec icon

Simple Thread

Gistrec | PRO | 04/11/18 06:00:58 AM UTC | 0 ⭐ | 727 👁️ | Never ⏰ | []
C++ |

410 B

|

None

|

0 👍

/

0 👎

#include <thread>
#include <iostream>
#include <vector>
#include <chrono>
 
void sleepThread(int sec, int number) {
    std::this_thread::sleep_for(std::chrono::milliseconds(sec * 1000));
    std::cout << "Therad " << number << " end work" << std::endl;
}
 
int main() {
    std::thread first(sleepThread, 5, 0);
    std::thread second(sleepThread, 2, 1);
    second.join();
    first.join();
    system("pause");
    return 0;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎