PRIORITY of Thread
来源:互联网 发布:永恒战士3mac版 编辑:程序博客网 时间:2024/05/22 05:13
public class TestJoin {
public static void main(String[] args) {
MyThread myThread = new MyThread("one");
MyThread otherThread = new MyThread("other");
myThread.setPriority(Thread.NORM_PRIORITY+4);
myThread.start();
otherThread.start();
}
}
class MyThread extends Thread {
public MyThread(String s) {
super(s);
}
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println("I am" + getName()+" " + i);
Thread.yield();
}
}
}
Result:
I amone 0
I amother 0
I amone 1
I amone 2
I amone 3
I amone 4
I amone 5
I amone 6
I amone 7
I amone 8
I amone 9
I amother 1
I amother 2
I amother 3
I amother 4
I amother 5
I amother 6
I amother 7
I amother 8
I amother 9
结论:one线程的优先级高于other,但并不是other线程没有执行的机会,而是拥有的时间片少于one的
- PRIORITY of Thread
- android 改变线程优先级Change Thread Priority
- 改变线程优先级Change Thread Priority
- The thread priority in UI application
- Thread Scheduling and Priority in Java
- How to schedule the thread's priority?
- [Java] Thread-03 Priority -01 、TestThread6
- Priority
- WinCE 5 kernel thread priority真的很厉害
- ERROR: Power Handler function yield to low priority thread 解决办法
- ERROR: Power Handler function yield to low priority thread. 解决方法
- unity 打包到手机出现thread priority security exception
- What is Java thread priority? 什么是java线程优先级
- Exercise of Thread(1)
- Exercise of Thread(2)
- Exercise of Thread(3)
- states of the thread
- Thread Safety of shared_ptr
- Windows驱动开发WDM (11)- 多个设备对象(同一个驱动)
- Warning: No grammar constraints (DTD or XML schema) detected for the document
- c++编译器为什么不支持模板的分离式编译
- Lucene搜索过程解析(8)
- 学习开源代码的方法
- PRIORITY of Thread
- 自旋锁spin_lock和raw_spin_lock
- C#调用C++编写的COM DLL
- UML 中 Attribute(屬性)與 Operation (操作)的完整語法
- TableView详细解释
- 程序员与黑客的故事 程序员应有的工作素质
- out和ref
- io 中的 mark()方法和reset()方法
- S3C6410启动模式介绍