我在应用中遇到以下问题: 为了在后台执行某些操作,我声明了一个ThreadPoolExecutor
private static ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(5, 100,
100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100));
然后我运行任务
poolExecutor.execute (new Runnable() {
public void run() {
Process.getThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
...
}
但该应用程序在此时崩溃说:
java.lang.IllegalArgumentException: Given thread does not exist
代码问题是什么?感谢
答案 0 :(得分:1)
您可能需要setThreadPriority
而不是getThreadPriority
poolExecutor.execute (new Runnable() {
public void run() {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
...
}