计算机基础
文章平均质量分 95
祥先生
名师指路不如自己去悟;自己不悟神仙也难救
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Lock vs Semaphore vs Condition Variable vs Monitor(中文)
在多线程(并发)程序中,多个线程会访问同一个共享内存,为了避免产生一些奇怪的结果,这些线程应该按照合适的顺序访问共享内存,这个过程称为同步(synchronization)。仅仅保持同步还不够,为了让同步更加高效,多个线程互相之间保持交流。1.Critical Section(CS)临界区(Critical section)是程序的一段代码块,临界区不能被多个线程在同一时间访问,临界区的访问是互斥的,某一时刻最多只有一个线程能进临界区。2.LockLock提供了一种互斥的方式,Lo...原创 2020-12-28 10:14:17 · 1365 阅读 · 1 评论 -
Lock vs Semaphore vs Condition Variable vs Monitor
目录1. Critical Section(CS)2. Lock3. Semaphore4. Condition variable5. Monitor6. SummaryIn mutil-threads (concurrent) programing, two or more threads have access to a shared memory, for avoiding confusing results, these threads should acces...原创 2020-12-25 17:45:15 · 423 阅读 · 0 评论 -
ThreadLocal原理的秘密
目录1. ThreadLocal描述2. 认识ThreadLocalMap3. 神奇的数字4.注意1. ThreadLocal描述ThreadLocal保证了每个线程都有自己独享的变量,不用考虑并发同步的问题。通常情况下,ThreadLocal类型的变量被建议声明为static,即使多个线程调用多次,该变量也只会初始化一次。ThreadLocal使用起来很简单、方便,但非常值得弄清ThreadLocal的实现原理。2. 认识ThreadLocalMap在ThreadLo.原创 2020-12-11 15:02:38 · 338 阅读 · 1 评论 -
The secret of ThreadLocal
ThreadLocal variable guareente each thread has own variable without thinking about synchronization. Usually threadlocal is declared static to be initialized only once whenever thread access it. We can easily use threadlocal in programm, but it is worth t原创 2020-12-11 10:42:12 · 189 阅读 · 0 评论 -
Producer-Consumer solution using wait(), notify(), park() and unpark()
1. IntroduceIn java, mutil-threads are used everywhere, applicationsnot only take advantages of mutil-threads improving efficiency, but also encounter some confusing problems especially when threads are not synchronized correctly. Fortunately, java prov.原创 2020-11-26 16:59:34 · 262 阅读 · 0 评论 -
What is thread in java and how its methods behave
1. What is ThreadAs in oracle java specification, thread is one of two basic units of execution, the other is process. Process was present prior to thread, we can refer to one process as an application. When an application is running, the resources alloc原创 2020-11-10 17:11:29 · 179 阅读 · 0 评论 -
重识JVM(2) - JAVA内存模型
目录一、概念和误解二、疑问三、计算机的内存模型3.1. 内存顺序和程序顺序3.2. SC内存模型3.3. TSO内存模型3.4. 其他内存模型3.5.JAVA内存模型3.6. volatile实现原理一、概念和误解 java内存模型,英文全称为java memory model,简称JMM。网上大部分关于java内存模型的资料都是关于堆栈...原创 2019-12-20 15:51:45 · 460 阅读 · 0 评论 -
计算机为什么要用补码
目录1. 补码诞生的背景2. 原码、反码、补码2.1 原码2.2 反码2.3 补码3. 加减法3.1普通算术加减法3.2模N加减法4. 总结1. 补码诞生的背景 不论是在生活中还是虚拟网络中,人们总是习惯与10进制数字打交道,很容易理解10进制的加减乘除运算,但是我们知道计算机无法直接理解10进制,只能识别高低电平,一般人为设定0为低电平...原创 2019-06-12 16:48:29 · 17126 阅读 · 18 评论
分享