============ Problem Description ============
Executorservice pool = Executors.newfixedthreadpool (2);
The Runnable interface object is created, and the thread object, of course, implements the Runnable interface.
Thread T1 = new MyThread ();
Thread t2 = new MyThread ();
Thread t3 = new MyThread ();
Thread T4 = new MyThread ();
Thread T5 = new MyThread ();
Putting a thread into the pool for execution
Pool.execute (t1);
Pool.execute (T2);
Pool.execute (T3);
Pool.execute (T4);
Pool.execute (T5);
The above creates a thread pool that is fixed to 2 threads, and at some point there is no way to judge whether T1, T2, T3, T4, T5 are waiting in line, or are already executing, because I want to cancel the task that is waiting in line, lest waste resources
Note: I use the first method in this article http://blog.csdn.net/lyf_007217/article/details/8542238
============ Solution 1============
Java.util.concurrent.ExecutorService;
Java.util.concurrent.Executors;
Look at the APIs inside these two packages.
============ Solution 2============
Intentservice provides a worker thread queue.
============ Solution 3============
To cancel, implement the callable interface, then call the Pool.submit () method, return the Futrue object, and use the future object to get the state of the thread.
These are the things inside J U C.
SOURCE analysis See:
http://blog.csdn.net/windsunmoon/article/details/36903901
Tasks in the Android thread pool are canceled