multithreading - How to stop a java 8 lambda-runnable-thread -
i stop thread:
runnable run= ()->{while(true)[...];}; run.run(); but there no run.stop() method.
please suggest either other short possible method start , stop thread or method stop running... thing.
runnable.run() not create thread. you're invoking run() method in current thread. create thread need that: create , start thread:
thread t = new thread(run); t.start(); then later on can invoke
t.interrupt(); please read javadocs on thread.interrupt() on how construction run() method interruptable.
java multithreading runnable
No comments:
Post a Comment