摘要:
AbortPolicy:抛出RejectedExecutionException异常,拒绝该任务的执行。 阅读全文
posted @ 2023-08-30 17:54
Ashe|||^_^
阅读(33)
评论(0)
推荐(0)
摘要:
private static final ThreadLocal<Integer> THREAD_LOCAL = new ThreadLocal<>(); @Test void threadLocalTest() { Assertions.assertDoesNotThrow(() -> { // 阅读全文
posted @ 2023-08-30 17:04
Ashe|||^_^
阅读(35)
评论(0)
推荐(0)
摘要:
Reentrantlock默认是非公平锁 private static ReentrantLock lock = new ReentrantLock(); 若想实现公平锁,只需使用重载构造器,fair参数传入true private static ReentrantLock lock = new R 阅读全文
posted @ 2023-08-30 16:40
Ashe|||^_^
阅读(102)
评论(0)
推荐(0)
摘要:
synchronized 关键字用于实现对象级别的同步,它可以保证多个线程在访问某个对象时的互斥性,避免并发访问导致的数据竞争和不一致 public class BankAccount { private BigDecimal balance; public BankAccount(String i 阅读全文
posted @ 2023-08-30 15:40
Ashe|||^_^
阅读(60)
评论(0)
推荐(0)

浙公网安备 33010602011771号