当前位置:网站首页>Interview question: what are the functions of fail safe mechanism and fail fast mechanism
Interview question: what are the functions of fail safe mechanism and fail fast mechanism
2022-07-27 22:00:00 【Xiao Zhao, who is working hard for millions of annual salary】
Hello, I'm Qingwei , A delusion 30 Beipiao programmers with an annual salary of millions before the age of .
This column is the common interview questions of big factories that I sorted out , I will give answers and explanations , I hope I can help you
If it helps , Welcome to my other columns :
link : Explore the principles from the source codelink : Java Concurrent programming
link : SQL– Knowledge and principle
Some time ago, a classmate went for an interview , Meet such a problem .
fail-safe Mechanism and fail-fast What is the role of the mechanism ?
He said when he heard the question , My mind is full of question marks .
forehead …. Um. …( After a few seconds , Post a funny picture , such as two years latter And so on , Then match A face blinded ..)
fail-safe Mechanism and fail-fast What are the mechanisms Modus effect
fail-safe and fail-fast, It is a failure handling mechanism for multithreaded concurrent operation collection .
Fail-fast: Express a quick failure , During collection traversal , Once the data in the container is found to have been modified , It will be thrown out immediately ConcurrentModificationException abnormal , This leads to traversal failure , In a situation like this .
Usually used in conjunction with iterators , For example, define a Map aggregate , Use Iterator Iterator for data traversal , In the process of traversing , When making changes to set data , It will happen fail-fast.
java.util The collection classes under the package are all of fast failure mechanism .
Common use fail-fast Way to traverse the content Device has HashMap and ArrayList etc. .
Fail-safe, Indicates failed security , That is, under this mechanism , The modification of set elements appears , I can't throw it Out ConcurrentModificationException.
The reason is the collection container with security failure mechanism , Not directly accessed on the collection content when traversing , Instead, copy the contents of the original collection first , Traversing over the set of copies .
Because the iteration is to traverse the copy of the original set , Therefore, changes made to the original set during traversal cannot be detected by the iterator , such as , Defined a CopyOnWriteArrayList, In the process of traversing this collection , After modifying the set elements , Does not throw an exception , But at the same time, the added elements will not be printed .
java.util.concurrent The containers under the package are all security failed , It can be used concurrently in multithreading , Concurrent modification .
often see Of Of send use fail-safe Fang type All over calendar Of Rong device Yes ConcerrentHashMap and CopyOnWriteArrayList etc. .
边栏推荐
- Will the United States prohibit all Chinese enterprises from purchasing American chips? Trump responded like this
- Inertial navigation principle (VII) -imu error classification (II) -allan variance analysis method +imu test + calibration introduction
- Station B collapsed. If we were the developer responsible for the repair that night
- Understanding of L1 regularization and L2 regularization [easy to understand]
- Lvs+kept highly available cluster
- 声扬科技正式上线闻声远程声纹健康回访服务系统!
- [numerical analysis exercise] numerical integration (complex trapezoid, complex Simpson, Romberg integral) C with STL implementation
- IDEA连接MySQL数据库并执行SQL查询操作
- Software testing interview question: when does the software testing project start? Why?
- For 3nm and below processes, ASML new generation EUV lithography machine exposure
猜你喜欢

Idea connects to MySQL database and performs SQL query operations
![[question 24] logic closed loop (Beijing Institute of Technology / Beijing University of Technology / programming methods and practice / primary school)](/img/c4/71a9933a3a1fdd14f84a41b640f5b5.jpg)
[question 24] logic closed loop (Beijing Institute of Technology / Beijing University of Technology / programming methods and practice / primary school)

聊聊 MySQL 事务二阶段提交

Pythia: Facebook's latest open source visual and language multitasking learning framework

8000 word explanation of OBSA principle and application practice

day 1 - day 4
![[question 21] idiom Solitaire (Beijing Institute of Technology / Beijing University of Technology / programming methods and practice / primary school)](/img/dd/5ef46cff3988db57bfaf6fe925a0e0.jpg)
[question 21] idiom Solitaire (Beijing Institute of Technology / Beijing University of Technology / programming methods and practice / primary school)

How to deal with high concurrency deadlock?

Finish learning redis cluster solution at one go

Monitor the running of server jar and restart script
随机推荐
Software testing interview question: what project documents need to be referred to in designing the system test plan?
@The difference between Autowired annotation and @resource annotation
内部类(四种内部类详解)
Commercial delay of self-developed 5g chip? Apple iPhone will adopt Qualcomm 5g chip in the next four years
Qt取出输入框字符串,lineEdit
8000字讲透OBSA原理与应用实践
@Autowired注解与@Resource注解的区别
软件测试面试题:软件测试项目从什么时候开始?为什么?
How long will it take to learn the four redis cluster solutions? I'll finish it for you in one breath
More than 100 lines should be split into functions
软件测试面试题:在windows下保存一个文本文件时会弹出保存对话框,如果为文件名建立测试用例,等价类应该怎样划分?
Oppo core making plan officially announced: the first chip or oppo M1
Station B collapsed. What did the developer responsible for the repair do that night?
[numerical analysis exercise] numerical integration (complex trapezoid, complex Simpson, Romberg integral) C with STL implementation
Software testing interview question: what is the focus of unit testing, integration testing, and system testing?
[question 21] idiom Solitaire (Beijing Institute of Technology / Beijing University of Technology / programming methods and practice / primary school)
Import word document pictures blocking and non blocking IO operations
高并发遇到死锁了,如何搞?
How to learn object Defineproperty | an article takes you to quickly learn
紫光展锐:2020年将有数十款基于春藤510的5G终端商用
