If I call in my main function std::this_thread::sleep_for(std::chrono::seconds(1))
and I create 2 threads (using std::thread
) and I have 1 cpu core.
Are there any context switching to main thread during this time? Or maybe only after 1 second there will be context switch to main thread?
i don't know how it works... I think there are two possibilities:
1) System many times switches to main context, after that checks that time is not over and switches, does nothing and switches to another thread 2) There is system interruption that switches context when time is over