摘要: lock 这里的lock只需要一把锁 因为同时还要配合状态 一起决定 一定要在try里面用 一定要unlock public class Test { public static void main(String[] args) { //传统版本 AirConditional airConditio 阅读全文
posted @ 2021-09-10 10:55 常熟阿诺 阅读(55) 评论(2) 推荐(0) 编辑
摘要: 和队列的offer和poll不同 阻塞队列是put和take 和list同级 常用的三个:array,list(默认是int.max)和synchronous(这个不存元素,只有单个) 停摆之前操作 只能在take之前去操作 不然就完蛋 如果第二个take写在新线程之前,自己的两个打印都会卡住 cl 阅读全文
posted @ 2021-09-10 09:17 常熟阿诺 阅读(8) 评论(0) 推荐(0) 编辑
摘要: countdown class q{ public static void main(String[] args) throws InterruptedException { CountDownLatch countDownLatch = new CountDownLatch(5); for (in 阅读全文
posted @ 2021-09-09 21:16 常熟阿诺 阅读(37) 评论(0) 推荐(0) 编辑
摘要: ###二维 import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int v = sc.nextInt(); int n 阅读全文
posted @ 2021-09-08 16:37 常熟阿诺 阅读(28) 评论(0) 推荐(0) 编辑
摘要: public class SkipList { class Node{ int value = -1; int level; //这里用的数组 Node[] next; public Node(int value, int level) { this.value = value; this.leve 阅读全文
posted @ 2021-09-08 14:27 常熟阿诺 阅读(55) 评论(0) 推荐(0) 编辑
摘要: class LRUCache { //自建一个类 class DNode{ int k; int v; DNode pre; DNode next; public DNode(){}; public DNode(int kk,int vv){k = kk;v = vv;}; } //自己的属性 pr 阅读全文
posted @ 2021-09-08 14:26 常熟阿诺 阅读(94) 评论(0) 推荐(0) 编辑
摘要: public class SortedPrintMore extends Thread{ //由于是不同的Thread n最好是共享 //无锁化 int i; static int n; static Lock lock = new ReentrantLock(); static Condition 阅读全文
posted @ 2021-08-31 12:18 常熟阿诺 阅读(28) 评论(0) 推荐(0) 编辑
摘要: package offer; import java.util.concurrent.locks.ReentrantLock; /** * @DATE: 2021-08-31 * @TIME: 10:11 * @FUNCTION: 按序打印abc 因为是abc 所以需要引入属性 v2 无锁 */ p 阅读全文
posted @ 2021-08-31 12:13 常熟阿诺 阅读(40) 评论(1) 推荐(1) 编辑
摘要: public class SortedPrint implements Runnable{ int n; @Override public synchronized void run(){ //有个唤醒机制 while(true){ if(n>100) return; System.out.prin 阅读全文
posted @ 2021-08-31 10:10 常熟阿诺 阅读(13) 评论(0) 推荐(0) 编辑
摘要: class Solution { public void solveSudoku(char[][] board) { //最骚的一点:给递归函数一个返回值 直接调用 太帅了 bp(board); } private boolean bp(char[][] board){ for(int i =0;i 阅读全文
posted @ 2021-08-24 12:40 常熟阿诺 阅读(27) 评论(0) 推荐(0) 编辑