当前位置:网站首页>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. .
边栏推荐
- Why use MQ message oriented middleware? These questions must be solved
- 紫光展锐:2020年将有数十款基于春藤510的5G终端商用
- Openai issued a document to introduce the latest application of Dall · E 2: fully enter the field of artistic creation and design
- Huawei establishes global ecological development department: fully promote HMS global ecological construction
- 软件测试面试题:在windows下保存一个文本文件时会弹出保存对话框,如果为文件名建立测试用例,等价类应该怎样划分?
- How to realize a good knowledge management system?
- Who is the sanctity of the six Chinese enterprises newly sanctioned by the United States?
- 如何实现一个好的知识管理系统?
- Is log4j vulnerability still widespread?
- 自研5G芯片商用推迟?未来4年苹果iPhone都将采用高通5G芯片
猜你喜欢

深入理解递归的方法调用(含实例迷宫问题、汉诺塔、猴子吃桃、斐波拉契、阶乘))

Can JVM tuning be done with single core CPU and 1G memory?

B站崩了,如果我们是那晚负责修复的开发人员

Microsoft store can't download apps, vs2019 can't download plug-ins solution

@RequestParam注解的详细介绍

How to deal with high concurrency deadlock?

day 1 - day 4

B站崩了,那晚负责修复的开发人员做了什么?

Log4j vulnerability is still widespread and continues to cause impact
![[question 22] dungeons and Warriors (Beijing Institute of Technology / Beijing Institute of Technology / programming methods and practice / primary school)](/img/64/70fa9f47836e07dd41d9e283e50adb.jpg)
[question 22] dungeons and Warriors (Beijing Institute of Technology / Beijing Institute of Technology / programming methods and practice / primary school)
随机推荐
怎么还有人问 MySQL 是如何归档数据的呢?
CocoaPods 重装
Is it safe to open an account online now? Then choose which securities to open a securities account
Excalidraw:很好用的在线、免费「手绘」虚拟白板工具
How to realize a good knowledge management system?
异常-Exception
软件测试面试题:设计系统测试计划需要参考的项目文档?
纳微半导体65W 氮化镓(GaN)方案获小米10 Pro充电器采用
In depth understanding of recursive method calls (including instance maze problem, tower of Hanoi, monkey eating peach, fiboracci, factorial))
技术管理 - 一定要抓大放小
软件测试面试题:假设有一个文本框要求输入10个字符的邮政编码,对于该文本框应该怎样划分等价类?
2021-11-05 understand main method syntax, code block and final keyword
Unit-- read Excel
LinkedList underlying source code
微软商店无法下载应用,VS2019无法下载插件问题解决方案
Station B collapsed. What did the developer responsible for the repair do that night?
Exception -exception
项目分析(从技术到项目、产品)
Software test interview questions: the steps to write test cases by drawing cause and effect diagrams are___ And transforming the cause and effect diagram into a state diagram in five steps. What are
Member method and its parameter transmission mechanism
