brintos

brintos / llvm-project-archived public Read only

0
0
Text · 771 B · 3bd736b Raw
36 lines · cpp
1// Test simulates situation when suspended thread could stop process2// where thread that is a real reason of stop says process3// should not stop in it's action handler.4 5#include <chrono>6#include <thread>7 8void thread1() {9  // Will be suspended at breakpoint stop10  // Set first breakpoint here11}12 13void thread2() {14  /*15   Prevent threads from stopping simultaneously16   */17  std::this_thread::sleep_for(std::chrono::seconds(1));18  // Set second breakpoint here19}20 21int main() {22  // Create a thread23  std::thread thread_1(thread1);24 25  // Create another thread.26  std::thread thread_2(thread2);27 28  // Wait for the thread that was not suspeneded29  thread_2.join();30 31  // Wait for thread that was suspended32  thread_1.join(); // Set third breakpoint here33 34  return 0;35}36