
Android 是一个专门针对移动设备的软件集,它包括一个操作系统,中间件和一些重要的应用程序。Beta版的 Android SDK 提供了在Android平台上使用JaVa语言进行Android应用开发必须的工具和API接口。 特性 应用程序框架 支持组件的重用与替换 Dalvik 虚拟机 专为移动设备优化 集成的浏览器 基于开源的WebKit 引擎 优化的图形库 包括定制的2D图形库,3D图形库基于
在多线程应用程序中,每个线程都被分配一个优先级。处理器根据线程的优先级(即最高优先级的线程先分配处理器,依此类推)由线程调度器分配给线程。线程的默认优先级为5。我们可以使用Thread类的getPriority()方法来获取线程的优先级。
在Thread类中,定义了三个静态值来表示线程的优先级:
MAX_PRIORITY
这是最高的线程优先级,值为10。
NORM_PRIORITY
这是默认的线程优先级,值为5。
MIN_PRIORITY
这是最低的线程优先级,值为1。
语法
public final int getPriority()
Example
public class ThreadPriorityTest extends Thread {
public static void main(String[]args) {
ThreadPriorityTest thread1 = new ThreadPriorityTest();
ThreadPriorityTest thread2 = new ThreadPriorityTest();
ThreadPriorityTest thread3 = new ThreadPriorityTest();
System.out.println("Default thread priority of thread1: " + thread1.getPriority());
System.out.println("Default thread priority of thread2: " + thread2.getPriority());
System.out.println("Default thread priority of thread3: " + thread3.getPriority());
thread1.setPriority(8);
thread2.setPriority(3);
thread3.setPriority(6);
System.out.println("New thread priority of thread1: " + thread1.getPriority());
System.out.println("New thread priority of thread2: " + thread2.getPriority());
System.out.println("New thread priority of thread3: " + thread3.getPriority());
}
}输出
Default thread priority of thread1: 5 Default thread priority of thread2: 5 Default thread priority of thread3: 5 New thread priority of thread1: 8 New thread priority of thread2: 3 New thread priority of thread3: 6










