Java多线程-暂停线程

1、暂停线程

  暂停线程意味着此线程还可以恢复运行。再Java多线程中,可以使 suspend() 方法暂停线程,使用 resume() 方法恢复线程的执行

2、suspend() 与 resume() 方法的缺点——独占

  在使用 suspend() 与 resume() 方法时,如果使用不恰当,极易造成公共的同步对象的独占,使得其他线程无法访问公共同步对象。

3、suspend() 与 resume() 方法的缺点——不同步

  在使用 suspend() 与 resume() 方法时也容易出现因为线程的暂停而导致数据不同步的情况。

猜你喜欢

转载自www.cnblogs.com/lkc9/p/12451589.html