小凡156

博客园 首页 新随笔 联系 订阅 管理

2020年7月22日 #

摘要: 1 1. 在指定文件夹中,右键git bash打开命令窗口 2 3 2.git init 初始化本地仓库 当前文件夹中会出现.git文件夹表示成功 4 5 3.git status 查看git状态 6 7 4.命名全局用户名和邮箱地址 8 9 git conifg --global user.nam 阅读全文
posted @ 2020-07-22 16:43 小凡156 阅读(481) 评论(0) 推荐(0) 编辑

2019年11月17日 #

摘要: Java内存模型 Java虚拟机规范定义Java内存模型(Java Memory Model,JMM) JMM的主要目标是定义程序中各个变量的访问规则,即在虚拟机中将变量存储到内存和从内存中取出变量。(变量包括:实例字段、静态字段和构成数组对象的元素,不包括局部变量和方法参数,因为后者是私有的,不会 阅读全文
posted @ 2019-11-17 22:04 小凡156 阅读(119) 评论(0) 推荐(0) 编辑

2019年11月10日 #

摘要: 如上图,红框中表示OjectMonitor的enter方法一进来就通过CAS将OjectMonitor的_owner设置为当前线程,绿框中表示设置成功的逻辑,第一个if表示重入锁的逻辑,第二个if表示第一次设置_owner成功,都意味着竞争锁成功,而我们的线程C显然是竞争失败的,会进入下图中的无线循 阅读全文
posted @ 2019-11-10 16:48 小凡156 阅读(368) 评论(0) 推荐(0) 编辑

摘要: 此时的线程C无法进入synchronized{}代码块,用jstack看应该是BLOCKED状态,如下图: 我们看看monitorenter指令对应的源码吧,位置:openjdk/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp 1 IR 阅读全文
posted @ 2019-11-10 16:28 小凡156 阅读(702) 评论(0) 推荐(0) 编辑

摘要: 1 void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { 2 3 Thread * Self = THREAD ; 4 5 if (THREAD != _owner) { 6 7 if (THREAD->is_lock_owned((a 阅读全文
posted @ 2019-11-10 16:16 小凡156 阅读(268) 评论(0) 推荐(0) 编辑

摘要: 1 // Consider: 2 3 // If the lock is cool (cxq == null && succ == null) and we're on an MP system 4 5 // then instead of transferring a thread from th 阅读全文
posted @ 2019-11-10 16:03 小凡156 阅读(291) 评论(0) 推荐(0) 编辑

摘要: 1 // Wait/Notify/NotifyAll 2 3 // 4 5 // Note: a subset of changes to ObjectMonitor::wait() 6 7 // will need to be replicated in complete_exit above 8 阅读全文
posted @ 2019-11-10 15:43 小凡156 阅读(347) 评论(0) 推荐(0) 编辑

2019年11月4日 #

摘要: 1 UPDATE test.MyT SET mark1 = (CASE WHEN content LIKE '%ce%' THEN 'c' ELSE NULL END), 2 mark2 = (CASE WHEN content LIKE '%d9999%' THEN 'd' ELSE mark2 END) 阅读全文
posted @ 2019-11-04 22:54 小凡156 阅读(355) 评论(0) 推荐(0) 编辑

2019年11月2日 #

摘要: 总结: Thread类中的static boolean interrupted()修改中断状态为false ,boolean isInterrupted()只判断中断状态,但不修改 public void interrupt() 将调用者线程的中断状态设置为true; public boolean 阅读全文
posted @ 2019-11-02 14:56 小凡156 阅读(239) 评论(0) 推荐(0) 编辑

摘要: 1 package sun.nio.ch; 2 3 public abstract interface Interruptible 4 { 5 public abstract void interrupt(Thread paramThread); 6 } 1 /** 中断此线程。 2 * Inter 阅读全文
posted @ 2019-11-02 14:09 小凡156 阅读(238) 评论(0) 推荐(0) 编辑