![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Backend
文章平均质量分 53
一个相爱相杀的程序员
这个作者很懒,什么都没留下…
展开
-
为什么StringBuilder线程不安全
StringBuilder相比StringBuffer效率更高,但多线程不安全; 在单线程中字符串的频繁拼接使用StringBuilder效率更高,对于多线程使用StringBuffer则更安全; 字符串简单操作时没必要使用上述两者,还是用String类型提高速度; @HotSpotIntrinsicCandidate public StringBuilder append(String str) { super.append(str); return this; } /** * A.原创 2021-01-11 13:05:48 · 129 阅读 · 0 评论 -
深入理解Volatile
Volatile的原理:volatile变量修饰的共享变量进行写操作时会在汇编代码前加上lock前缀,lock前缀的指令在多核处理器下会引发两件事情: 将当前处理器缓存行的数据写回到系统内存 该写回内存的操作会使在其他CPU里缓存了该内存地址的额数据无效 Volatile特性之一:保证线程之间的可见性 保证变量在线程之间的可见性。可见性的保证是基于CPU的内存屏障指令,被JSR-133抽象为happens-before原则。 Volatile特性之二:禁止指令重排 阻止编译时和运行时的指令重排。编译时J原创 2021-01-11 12:48:16 · 115 阅读 · 1 评论 -
git rebase/ git commit --amend
git commit --amend --no-edit 合并提交 git push -f git rebase -I [commit id] # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous原创 2021-01-07 14:29:47 · 344 阅读 · 0 评论 -
git merge 和 git rebase 小结
1. git merge git merge是用来合并两个分支的。 git merge b 将b分支合并到当前分支 同样 git rebase b,也是把 b分支合并到当前分支 他们的 原理 如下: 假设你现在基于远程分支"origin",创建一个叫"mywork"的分支。 $ git checkout -b mywork origin 假设远程分支"origin"已经有了2个提交,如图 现在我们在这个分支做一些修改,然后生成两个提交(commit). $ vi file.txt $ git com转载 2021-01-05 19:37:14 · 81 阅读 · 0 评论