Skip to content

Commit

Permalink
update: 更新链接
Browse files Browse the repository at this point in the history
  • Loading branch information
wardseptember committed Oct 25, 2020
1 parent 1605201 commit 7c915c6
Show file tree
Hide file tree
Showing 4 changed files with 488 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@

关注我获得最新笔记、更多资源

<div align="center"> <img src="https://gitee.com/wardseptember/images/raw/master/imgs/20201013164148.png
" width="600"/> </div><br>
<div align="center"> <img src="https://gitee.com/wardseptember/images/raw/master/imgs/gzh.jpg" width="600"/> </div><br>


## GPL v2.0
[LICENSE](https://github.com/wardseptember/notes/blob/master/LICENSE)
Expand Down
2 changes: 2 additions & 0 deletions docs/spring/spring基础.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ MVC 是一种设计模式,Spring MVC 是一款很优秀的 MVC 框架。Spring M
7. `DispaterServlet` 把返回的 `Model` 传给 `View`(视图渲染)。
8.`View` 返回给请求者(浏览器)

**SpringMVC通过DispatcherServlet拦截所有的请求, 并通过HandlerMapping与指定的请求找出匹配的handler, handler实际是HandlerMethod对象。 再通过与handler适配的HandlerAdapter执行目标方法, 执行完目标方法后会返回ModelAndView对象, 最后通过ViewResolver解析ModelAndView的View视图。**

更详细教程:

* https://github.com/Snailclimb/JavaGuide/blob/master/docs/system-design/framework/spring/SpringMVC-Principle.md
Expand Down
20 changes: 20 additions & 0 deletions docs/多线程和高并发.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,10 @@ volatile作用:

Volatile并不能保证多个线程共同修改running变量说带来的不一致性问题,也就是说volatile不能替代synchronized



```java

import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -447,8 +450,11 @@ volatile作用:
System.out.println(t.count);
}
}

```



count++被编译成字节码,会分成三个指令,第一个从主内存拿到原始count,第二个在工作线程中执行+1操作,第三把累加后的值写回主内存。

上面的程序输出count的结果并不是10000,这是因为volatile不能保证原子性导致的脏读。对m()加synchronized关键字可以保证原子性,count最后结果一定是10000
Expand All @@ -459,7 +465,10 @@ volatile作用:

下面代码几秒之内并不会输出"m end!"



```java

import java.util.concurrent.TimeUnit;

public class T02_VolatileReference1 {
Expand Down Expand Up @@ -490,8 +499,11 @@ volatile作用:
T.running = false;
}
}

```



#### Volatile实现原理

* 可见性实现原理
Expand Down Expand Up @@ -1068,7 +1080,10 @@ reentrantlock可用于替代synchronized,它比synchronized的功能更强大

3. 使用ReentrantLock还可以调用lockInterruptibly方法,可以对线程interrupt方法做出响应。



```java

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
Expand Down Expand Up @@ -1118,8 +1133,11 @@ reentrantlock可用于替代synchronized,它比synchronized的功能更强大

}
}

```



4. ReentrantLock还可以指定为公平锁

```java
Expand Down Expand Up @@ -2092,6 +2110,8 @@ ThreadLocal使用完了,手动remove掉。

插入效率低一些,查询时效率高。

教程见[ConcurrentHashMap详解(基于1.71.8)](https://wardseptember.gitee.io/mynotes/#/docs/ConcurrentHashMap详解(基于1.7和1.8))

### ConcurrentSkipListMap

是一个有序的并发Map
Expand Down
Loading

0 comments on commit 7c915c6

Please sign in to comment.