public class CustomScheduledExecutor extends ScheduledThreadPoolExecutor {
static class CustomTask implements RunnableScheduledFuture { ...
protected RunnableScheduledFuture decorateTask(
Runnable r, RunnableScheduledFuture task) {
return new CustomTask(r, task);
}
我一直在尝试在 android 应用程序中使用 ScheduledThreadPoolExecutor,但它与在 java 应用程序中的工作方式不同
}
@Override
public void onClick(View view)
{
Runnable runner = new Runnable()
{
@Override
public void run()
{
rollthedice();
}
};
if(view == continuous)
{
if(now == null)
{now = scheduler.scheduleAtFixedRate(runner, 0, 250, TimeUnit.MILLISECONDS);
}
else
return;
}
if(view == stop)
{
if(now != null)
{
now.cancel(true);
now = null;
}
else
return;
}
if(view == roll)
rollthedice();
if(view == exit)
System.exit(0);
}
}
这是我的代码,我无法让连续按钮继续运行,如果它是一个 java 应用程序,它会正常工作