为了这; 我希望“Continuous”按钮开始 rollthedice(),并希望“Stop”按钮停止它,但是当我再次点击“Continuous”按钮时,我希望它再次来回启动 rollthedice()
scheduler = new ScheduledThreadPoolExecutor(1);
ScheduledFuture now = null;
Runnable runner = new Runnable(){
public void run()
{
rollthedice();
}
};
if(e.getSource()==continuous)
{
now = scheduler.scheduleAtFixedRate(runner, 0, 500, TimeUnit.MILLISECONDS);
}
if(e.getSource()==stop)
{
now.cancel(true);
}