我有这样的代码
Create thread_1 and bind task 1 to that; Create thread_2 and bind task 2 to that; Create thread_3 and it monitors the keyboards and work as follow: while(true){ get the next key; if (the next key == 'p') pause_the_code(); if (the next key == 'r') resume_the_code(); if(the next key == 'q' exit the while loop } // can I here block the Thread_1 and _Thread_2 with all of their children //with wait() when I call pause_the_code(); or notify them when I call resume_the_code();
请注意,hread_1和Thread_2可以动态创建不同的线程。
我有这样的代码创建线程_1并将任务1绑定到该代码;创建thread_2并将任务2绑定到该线程;创建thread_3并监视键盘并按以下方式工作:while(true){...
否,您无法从一个线程伸出手来暂停或阻止另一个线程。并非以任何安全的方式。