2023年3月4日

摘要: package com.Java;//守护线程//虚拟机不需要等待守护线程执行完//虚拟机必须等待用户线程执行完public class TestDaemon { public static void main(String[] args) { God god = new God(); Yous y 阅读全文
posted @ 2023-03-04 17:09 搁浅fff 阅读(12) 评论(0) 推荐(0) 编辑
 
摘要: package com.Java;//线程优先级调度// 注意:不是调整了优先级就一定会被cpu先执行 只是提高了执行概率 一切还是要看cpu调度public class TestPriority { public static void main(String[] args) { System.o 阅读全文
posted @ 2023-03-04 16:39 搁浅fff 阅读(31) 评论(0) 推荐(0) 编辑
 
摘要: package com.Java;//观测线程状态public class TestState { public static void main(String[] args) throws InterruptedException { Thread thread = new Thread(() - 阅读全文
posted @ 2023-03-04 16:15 搁浅fff 阅读(15) 评论(0) 推荐(0) 编辑
 
摘要: package com.Java;//Join 线程插队 必须执行完再执行其他线程public class TestJoin implements Runnable { @Override public void run() { for (int i = 0; i < 500; i++) { Sys 阅读全文
posted @ 2023-03-04 14:27 搁浅fff 阅读(10) 评论(0) 推荐(0) 编辑
 
摘要: package com.Java;//线程礼让 礼让不一定成功public class TestYield { public static void main(String[] args) { MyYield yield = new MyYield(); new Thread(yield, "a") 阅读全文
posted @ 2023-03-04 14:16 搁浅fff 阅读(9) 评论(0) 推荐(0) 编辑
 
摘要: package com.Java;import java.text.SimpleDateFormat;import java.util.Date;//每个对象都有一个锁 sleep不会释放锁public class TestSleep { public static void main(String 阅读全文
posted @ 2023-03-04 11:22 搁浅fff 阅读(10) 评论(0) 推荐(0) 编辑
 
摘要: package com.Java;public class TestStop implements Runnable {// 测试线程停止// 1.建议线程正常停止 -->利用次数 不建议死循环// 2.建议使用标志位--> 设置一个标志位// 3.不要使用stop和destroy等过时和jdk不建 阅读全文
posted @ 2023-03-04 10:29 搁浅fff 阅读(9) 评论(0) 推荐(0) 编辑
 
摘要: package com.Java;public class Lambda1 { public static void main(String[] args) {// ILike ilike = null;// //可以有多个接口式函数// ilike = (int a)->{// }; Like l 阅读全文
posted @ 2023-03-04 09:52 搁浅fff 阅读(33) 评论(0) 推荐(0) 编辑