56.10 Working with Runnable Tasks
The first step in exploring this framework is to modify the buttonClicked() method to use a concurrency framework Executor to run the task in a separate thread:
.
.
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
.
.
public void buttonClick(View view) {
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(new Runnable(){
public void run(){
long endTime = System.currentTimeMillis() + 10 * 1000;
while (System.currentTimeMillis() < endTime) {
...