如何停止Runnable线程或“接口”(How do i stop a Runnable thread or “interface”)
我需要以某种方式停止此代码是否有任何方法可以做到这一点。 如果有人可以回答问题并发布链接到你可以学习线程的地方,我就不和线程保持一致了,但是在开始的时候我没有读过很多关于java的书籍基础知识有点轻松,除了文件更改之类的东西BufferedWriters和东西。 所以任何可以微调基础知识或从哪里去的东西。 对不起,我在一个问题中有疑问。 :)
private final Runnable updateCircle = new Runnable() { @Override public void run() { lastColor = random.nextInt(2) == 1 ? redColor : greenColor; paint.setColor(lastColor); invalidate(); handler.postDelayed(this, 1000); } };
I need to stop this code somehow is there any way to do this. I'm not in tune with threads if someone could answer the question and post a link to where you can learn threading, but not at the beginning level ive read many books on java the basics kinda come at an ease, except file changing stuff like BufferedWriters and stuff. So anything that could fine tune the basics or where to go from there. sorry i have a question in a question. :)
private final Runnable updateCircle = new Runnable() { @Override public void run() { lastColor = random.nextInt(2) == 1 ? redColor : greenColor; paint.setColor(lastColor); invalidate(); handler.postDelayed(this, 1000); } };
原文:https://stackoverflow.com/questions/29777838