2010-10-04 136 views

回答

0

您可以通過實現這樣的

while(true) { 
    if(paused) 
    { 
     try { 
      Thread.sleep(500); // half a second 
      continue; 
     } catch(InterruptedException e) 
     { 
     } 
    } 
} 

它是不是很漂亮但是你暫停在擺動工人運行任務。

+1

你從這裏複製代碼http://www.velocityreviews.com/forums/t136961-pausing-a-swing-worker-thread.html但忘了寫循環:-) – 2010-10-04 07:34:31

+0

正確。格式化它更好。 – Fedearne 2010-10-04 07:41:48

+1

不要這樣做。改用wait()和notify()。 – 2012-11-20 03:42:50