摘要: 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 n1ce2cv 阅读(201) 评论(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 n1ce2cv 阅读(33) 评论(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 n1ce2cv 阅读(53) 评论(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 n1ce2cv 阅读(446) 评论(0) 推荐(0) 编辑