摘要: JUC cpu多核 public class Test1 { public static void main(String[] args) { // 获取cpu核数 // cpu密集型 io密集型 System.out.println(Runtime.getRuntime().availablePr 阅读全文
posted @ 2021-09-28 16:30 _Sylvan 阅读(236) 评论(0) 推荐(0)
摘要: synchronized锁的内容 import java.util.concurrent.TimeUnit; class Test1 { public static void main(String[] args) { Phone phone = new Phone(); new Thread(() 阅读全文
posted @ 2021-09-28 16:30 _Sylvan 阅读(44) 评论(0) 推荐(0)
摘要: Lock锁 源码 Lock public interface Lock { void lock(); void lockInterruptibly() throws InterruptedException; boolean tryLock(); boolean tryLock(long time, 阅读全文
posted @ 2021-09-28 16:29 _Sylvan 阅读(66) 评论(0) 推荐(0)
摘要: 虚假唤醒 class A { public static void main(String[] args) { Data data = new Data(); // +1 new Thread(() -> { for (int i = 0; i < 10; i++) { try { data.inc 阅读全文
posted @ 2021-09-28 16:02 _Sylvan 阅读(488) 评论(0) 推荐(0)