17.Priority优先级
2024-08-28 15:57:14
/**
* 优先级
*/
public class PriorityDemo {
public static class HightPriority extends Thread{
static int count = 0;
@Override
public void run() {
while (true){
synchronized (PriorityDemo.class){
count++;
if (count>100000000){
System.out.println("HightPriority is complete");
break;
}
}
}
}
}
public static class LowPriority extends Thread{
static int count = 0;
@Override
public void run() {
while (true){
synchronized (PriorityDemo.class){
count++;
if (count>100000000){
System.out.println("LowPriority is complete");
break;
}
}
}
}
}
public static void main(String[] args){
HightPriority hightPriority = new HightPriority();
LowPriority lowPriority = new LowPriority();
hightPriority.setPriority(Thread.MAX_PRIORITY);//高优先级
lowPriority.setPriority(Thread.MIN_PRIORITY);//低优先级
lowPriority.start();
hightPriority.start();
}
//HightPriority is complete
//LowPriority is complete
}
最新文章
- 查看sqlserver被锁的表以及如何解锁
- JointBoost+CRF+GraphCut做手绘草图的分割
- 手机QQ内置网页,微信内置网页中进行分享到QQ和微信的操作
- iOS开发拓展篇—CoreLocation定位服务
- poj 1724(有限制的最短路)
- Qt 5 如何修改打包好的应用程序图标
- jsp文件中的路径问题
- perl 爬取上市公司业绩预告
- Carmichael Numbers - PC110702
- TensorFlow 代码行统计
- nuget安装本地nupkg文件
- 【译】第二篇 SQL Server安全验证
- SVD与SVD++
- docker登录运行中的容器的4方案
- 【读书笔记】iOS-使用传感器
- BodeAbp服务端介绍
- Linux 创建文件系统及挂载文件系统流程详解(转)
- 使用LiteOrm删除数据对象失败的坑
- 基于vue的web应用如何构建成手机端的原生安装包
- Java编程语言下 Selenium 驱动各个浏览器代码