Java多线程-暂停线程

1、暂停线程

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

 

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

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

 

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

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

posted @ 2020-03-09 21:12  lkc9  阅读(288)  评论(0编辑  收藏  举报