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);
}
红色部分帮错~~~该怎么办?
解决方案 »
- android客户端怎么把图片post给php服务端?
- 安卓监控软件的开发问题,请各位帮忙想想,分全部供上。。。
- 急急急:如何控制信息音,按键音,语音提示的开启与关闭。。。。。
- SQLiteDatabase如何实现update table set field=field+1
- 急求大牛指点:用webview通过加载本地网页里播放mp4问题
- 为什么在使用Android native Thread时报错Fatal signal 11 (SIGSEGV)?
- 安卓推送功能用服务来做,还是用定时的闹钟来做?
- android 开发 内存溢出问题
- E/AndroidRuntime(28782): java.lang.StackOverflowError
- 百度地图 MapView类 的 removeView接口为何不好使 急救大神解救!
- HAL_legacy和HAL的对比 的理解疑惑
- Android NDK编译的问题
(发消息->等回应)
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
楼主这里遇到的是编译错误。