当前位置:网站首页>Multithreading & high concurrency (the latest in the whole network: interview questions + map + Notes) the interviewer is calm
Multithreading & high concurrency (the latest in the whole network: interview questions + map + Notes) the interviewer is calm
2022-07-24 23:28:00 【Java misty rain】

Preface
When you start going to job hopping interviews , It's just a piece of 15K The job of , But ask if you can multithread , Do you understand high concurrency , Rockets are built to surprise you , It turns out to be cool ; Now the market , Multithreading 、 High concurrent programming 、 Distributed 、 Load balancing 、 Clusters and so on can be said to be the necessary skills for advanced back-end development and job hunting .
A lot of people have big factory dreams , But because Multithreading and high concurrency Defeat the battle . actually , Multithreading and high concurrency are not difficult , Today's most comprehensive summary of multithreading and high concurrency , Help you to the factory “ fire ”, The interview is no longer difficult to be multithreaded and high .
One 、 Multithreading and high concurrency ( Summary of interview questions )
Multithreaded and high concurrent test questions ( Base part )
How do you ensure main() The thread of the method is Java Last thread of program ?
ThreadLocal principle

ThreadLocal Memory structure diagram
What is a deadlock (Deadlock)? How to analyze and avoid deadlock ?
What is? Java Timer class ? How to create a task with a specific time interval ?
What is a thread pool ? How to create a Java Thread pool ?
What is the implementation of concurrent container ?
Executors What is the class ?
say something CountDownLatch And CyclicBarrier difference

Multithreaded and high concurrent test questions ( Advanced part )
What happens when you use synchronization on static methods ?
Can two threads call two different synchronous instance methods on an object ?
Fork/Join Understanding of the framework

What is a deadlock
volatile What is it? ? Can order be guaranteed ?
CAS?CAS What are the drawbacks , How to solve ?

Thread Class start() and run() What's the difference ?
Java in interrupted and isInterruptedd Differences in methods ?
How do I detect deadlocks ? How to prevent deadlock ? Four necessary conditions for deadlock

Multithreading and high concurrency interview answer parsing

The difference between multithreading and high concurrency
“ High concurrency and multithreading ” Always mentioned together , It feels like the two are equal , High concurrency ≠ Multithreading
1. Multithreading
Multithreading is java Characteristics of , Because now cpu It's all multi-core and multi-threaded , You can perform several tasks at the same time , In order to improve the jvm Efficiency of execution ,java Provides this multithreading mechanism , To enhance data processing efficiency . Multithreading corresponds to cpu, High concurrency corresponds to access requests , All access requests can be processed in a single thread , You can also use multithreading to process access requests at the same time .
In the past, single CPU Time , A single task can only execute a single program at a point in time . And then it's multi tasking , Computers can perform multitasking or multiprocessing in parallel at the same point in time . Although it's not really “ At the same time ”, Instead, multiple tasks or processes share one CPU, And leave it to the operating system to complete multi task CPU Running switch of , So that each task has a chance to run for a certain time .
Then it developed to multithreading technology , Make it possible to have multiple threads execute in parallel within a program . The execution of a thread can be thought of as a CPU In the execution of the program . When a program is running in multithreading , It's like there's more than one CPU Execute the program at the same time .
All in all , Multithreading can be understood in this way : Multithreading is a programming method to deal with high concurrency , That is, concurrency needs to be implemented by multithreading .
2. High concurrency
High concurrency is not JAVA Something exclusive to , It's a language independent, generalized , The concept of providing better Internet services .
Typical scenario , for example :12306 Grab the train ticket , Tmall double 11 second killing activities, etc . The occurrence of this situation will cause the system to perform a large number of operations during this period , For example, requests for resources , Database operation, etc . If high concurrency is not good , Not only does it reduce the user experience ( Request response time is too long ), At the same time, it may lead to system downtime , It can even lead to OOM abnormal , The system stops working, etc .
If you want the system to be able to adapt to high concurrency state , We need to optimize the system from all aspects , Include , Hardware 、 The Internet 、 System architecture 、 Selection of development language 、 The use of data structures 、 Algorithm optimization 、 Database optimization, etc …… Multithreading is only one of the solutions .
On the practical application of multithreading and high concurrency
Java High concurrent programming details : Multithreading and architecture design
The first part : Multithreading Foundation
Mainly on Thread Basic knowledge of , Introduce the thread in detail API Use 、 Thread safety 、 Data communication between threads , And how to protect shared resources , It's the foundation for deep learning of multithreaded content .


The second part :Java ClassLoader
Introduced ClassLoader, This is because ClassLoader It has something to do with threads , We can go through synchronized keyword , perhaps Lock The data consistency of shared resources is protected by explicit lock in the code writing stage , So one Class After completing the whole process of initialization, in the method area (JDK8 Later in metadata space ) How does its data structure ensure data consistency ? It needs to be right ClassLoader Have a more comprehensive understanding of .
The third part : In depth understanding of volatile keyword
The third part details 、 Introduce in depth volatile The semantics of keywords ,volatile The key word in Java It's very important , It's been laid down Java Efficient operation of the core and contract , In this part , We show how to use volatile Key words and a very detailed introduction to Java Memory model, etc .

The fourth part : Multithreading design architecture pattern
From the perspective of program architecture design, this paper explains how to design efficient and flexible multithreaded applications , This part is as long as 15 Chapters , Its importance can be seen in a little bit .



《 Multithreading and high concurrency 》
Section 1 : Basic concept of thread
In the second quarter :volatile And CAS
In the third quarter :Atomic Class and thread synchronization
The fourth quarter, :LockSupport、 Taobao interview questions and source code reading methodology
Section 5 :AQS Source code reading and strong weak virtual 4 Kinds of references and ThreadLocal Principle and source code
Section 6 : Concurrent container
Section 7 : Thread pool
Section 8 : Thread pool and source code reading
Section 9 :JMH And Disruptor


About learning multithreading and highly concurrent mind map
Multithreading and high concurrency (Xmind)
Disruptor, Basic concepts , High frequency interview bonus ,JUC Synchronization tool , Thread pool , Synchronization container

Conclusion
in general , If you have a big company you want to go to , We must improve ourselves , Match your ability and quality with the company , I've always believed in , Opportunity is always for those who are prepared . Whether it's study or work , There should be initiative , So if you have a big factory dream , Then we should try our best to realize it .
边栏推荐
- Network Security Learning (I) virtual machine
- 必会面试题:1.浅拷贝和深拷贝_浅拷贝
- WPF opens external programs and activates them when needed
- Process / thread synchronization mechanism
- Shell调试Debug的三种方式
- Can the income of CICC securities' new customer financial products reach 6%? How to open an account?
- The tragic experience of installing scikitlearn on win764
- Introduction to HLS programming
- Learn AI through detectron2
- 生成式对抗网络的效果评估
猜你喜欢

Piziheng embedded: the method of making source code into lib Library under MCU Xpress IDE and its difference with IAR and MDK

百度网盘+Chrom插件

用VS Code搞Qt6:编译源代码与基本配置

Add a little surprise to life and be a prototype designer of creative life -- sharing with X contestants in the programming challenge

Network Security Learning (IV) user and group management, NTFS

凸优化基础知识

Notes of Teacher Li Hongyi's 2020 in-depth learning series lecture 1

Effect evaluation of generative countermeasure network

Power consumption of chip

With screen and nohup running, there is no need to worry about deep learning code anymore | exiting the terminal will not affect the operation of server program code
随机推荐
Alibaba cloud SSL certificate
Talk about how redis handles requests
Okaleido tiger NFT is about to log in to binance NFT platform, and the future market continues to be optimistic
Can Baidu network disk yundetectservice.exe be disabled and closed
First engineering practice, or first engineering thought—— An undergraduate's perception from learning oi to learning development
The specified data is grouped and the number of repetitions is obtained in Oracle
HTB-Aragog
QT6 with vs Code: compiling source code and basic configuration
How to create and manage customized configuration information
Excel file processing tool class (based on easyexcel)
Financial products can reach 6%. I want to open an account to buy financial products
Upgrade the jdbc driver to version 8.0.28 and connect to the pit record of MySQL
MATLAB basic grammar (II)
Baidu online disk +chrome plug-in
买收益百分之6的理财产品,需要开户吗?
Go基础笔记_4_map
Network Security Learning (IV) user and group management, NTFS
激光雷达障碍物检测与追踪实战——cuda版欧式聚类
91. (leaflet chapter) leaflet situation plotting - offensive direction drawing
郑慧娟:基于统一大市场的数据资产应用场景与评估方法研究