localizations: #1771 Spanish translation and languages codes (#1777)

* #1771 Move translations to a new directory to have more organization

* #1771 spanish translation

* #1771 change the language codes to follow ISO 639-1 and change the links

* #1771 remove country flags
This commit is contained in:
Juan Manuel Abate
2021-06-04 20:36:42 +02:00
committed by GitHub
parent 5e434b783e
commit 784cdee819
67 changed files with 319 additions and 6 deletions

View File

@ -0,0 +1,21 @@
---
layout: pattern
title: Double Checked Locking
folder: double-checked-locking
permalink: /patterns/double-checked-locking/
categories: Idiom
tags:
- Performance
---
## 含义
通过先测试锁定标准("锁提示")而不实际获取锁的方式来减少获取锁的开销。只有当锁定标准检查表明需要锁定时,才进行实际的锁定逻辑。
## 类图
![alt text](../../double-checked-locking/etc/double_checked_locking_1.png "Double Checked Locking")
## 适用场景
在以下场景适合使用双重锁检查模式:
* 在创建对象时有存在并发的访问。如单例模式中,你想创建同一个类的单个实例,如果存在两个或更多的线程对实例进行判空,仅仅检查该该实例是否为空可能是不够的。
* 在一个方法上存在并发访问,该方法的行为是根据一些约束条件而改变,而这些约束条件在该方法中也会发生变化。