public class LoaderThread extends Thread{
public void run() {
android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
}
红色部分帮错~~~该怎么办?
public void run() {
android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
}
红色部分帮错~~~该怎么办?
(发消息->等回应)
2. 后台线程优先级要稍微低一点。
//这里面都是些耗时的操作,我把它放在线程里面做了~~~
}
public class LoaderThread extends Thread{
public void run() {
android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
updatetable();
}
可是这个动作丝毫不能起任何作用?
该怎么办?
* Set the priority of a thread, based on Linux priorities.
*
* @param tid The identifier of the thread/process to change.
* @param priority A Linux priority level, from -20 for highest scheduling
* priority to 19 for lowest scheduling priority.
*
* @throws IllegalArgumentException Throws IllegalArgumentException if
* <var>tid</var> does not exist.
* @throws SecurityException Throws SecurityException if your process does
* not have permission to modify the given thread, or to use the given
* priority.
*/看样子是调整process的nice值的,这个估计你apk是没有权限做的。
myThread.setPriority(xxxx)
start完了在设置它具体接口查下sdk吧,忘了
函数,最好不要和主线程有同步的东西,以免因为同步阻塞了主线程,造成ANR
android中有两个 Process 类
一个是 android.os.Process 一个是 java.lang.Process.
而java.lang包是默认导入的 所以楼主遇到的问题应该是 没有导入android.os.Process 类。
import一下 就ok了。 楼上都是大牛。
另外废话一句
没有加权限 是运行时异常 Runtime Exception
楼主这里遇到的是编译错误。