上一页 1 2 3 4 5 6 ··· 13 下一页
摘要: package com.guo.syn; import java.util.concurrent.CopyOnWriteArrayList; //测试JUC安全类型的集合 public class TestJUC { public static void main(String[] args) { 阅读全文
posted @ 2026-03-27 15:00 果子同志 阅读(2) 评论(0) 推荐(0)
摘要: synchronized 同步方法,锁的是this package com.guo.syn; //不安全买票 //线程不安全,有负数 public class UnsafeBuyTicket { public static void main(String[] args) { BuyTicket s 阅读全文
posted @ 2026-03-25 21:50 果子同志 阅读(2) 评论(0) 推荐(0)
摘要: 不安全的取钱 UnsafeBank package com.guo.syn; //不安全的取钱 public class UnsafeBank { public static void main(String[] args) { //账户 Account account = new Account( 阅读全文
posted @ 2026-03-25 18:04 果子同志 阅读(3) 评论(0) 推荐(0)
摘要: 并发 同一个对象被多个线程同时操作 线程同步 锁机制 synchronized 阅读全文
posted @ 2026-03-25 15:18 果子同志 阅读(3) 评论(0) 推荐(0)
摘要: thread.setDaemon(true); //默认是flase表示是用户线程,正常的线程都是用户线程 package com.guo.demo03.daemon; import com.sun.xml.internal.stream.util.ThreadLocalBufferAllocato 阅读全文
posted @ 2026-03-25 11:14 果子同志 阅读(1) 评论(0) 推荐(0)
摘要: package com.guo.demo03.priority; //测试线程的优先级 public class TestPriority { public static void main(String[] args) { //主线程默认优先级 System.out.println(Thread. 阅读全文
posted @ 2026-03-25 10:57 果子同志 阅读(5) 评论(0) 推荐(0)
摘要: Thread.State state = thread.getState(); package com.guo.demo03.state; //观察测试线程的状态 public class TestState { public static void main(String[] args) thro 阅读全文
posted @ 2026-03-25 10:39 果子同志 阅读(1) 评论(0) 推荐(0)
摘要: package com.guo.demo03.join; //测试join方法 public class TestJoin implements Runnable{ @Override public void run() { for (int i = 0; i < 1000; i++) { Syst 阅读全文
posted @ 2026-03-25 10:09 果子同志 阅读(1) 评论(0) 推荐(0)
摘要: package com.guo.demo03.yield; //测试礼让线程 //礼让不一定成功,看cpu心情 public class TsetYield { public static void main(String[] args) { MyYield myYield = new MyYiel 阅读全文
posted @ 2026-03-24 21:54 果子同志 阅读(2) 评论(0) 推荐(0)
摘要: 模拟倒计时 package com.guo.sleep; //模拟倒计时 public class TestSleep2 { public static void main(String[] args) { try { tenDown(); } catch (InterruptedException 阅读全文
posted @ 2026-03-24 21:35 果子同志 阅读(3) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 ··· 13 下一页