当前位置:网站首页>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 .
边栏推荐
- Vite3.0 has been released, can you still roll it (list of new features)
- Horizontally centered element
- Let me introduce you to the partition automatic management of data warehouse
- Browser cache
- Solve the problem that JSP cannot use session.getattribute()
- The tragic experience of installing scikitlearn on win764
- JS ------ Chapter 3 JS cycle
- Code coverage
- In pgplsql: = and=
- LP liquidity pledge mining system development detailed procedure
猜你喜欢

生成式对抗网络的效果评估

Network Security Learning (V) DHCP

MySQL查询慢的一些分析

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
WPF uses pathgeometry to draw the hour hand and minute hand

Alibaba cloud SSL certificate

Paper notes: accurate causal influence on discrete data

The specified data is grouped and the number of repetitions is obtained in Oracle

Implementation of cat and dog data set classification experiment based on tensorflow and keras convolutional neural network

郑慧娟:基于统一大市场的数据资产应用场景与评估方法研究
随机推荐
The rule created by outlook mail is invalid. Possible reasons
WPF opens external programs and activates them when needed
WPF uses pathgeometry to draw the hour hand and minute hand
Code coverage
Value driven provides the core driving force for the transformation of commercial BP - BP realization under business scenarios - Commercial BP sharing
LP liquidity pledge mining system development detailed procedure
Notes of Teacher Li Hongyi's 2020 in-depth learning series lecture 1
如何创建和管理自定义的配置信息
How to put long links into Excel
痞子衡嵌入式:MCUXpresso IDE下将源码制作成Lib库方法及其与IAR,MDK差异
Qt | 事件系统 QEvent
Go基础笔记_4_map
Bug summary
Can Baidu network disk yundetectservice.exe be disabled and closed
In pgplsql: = and=
Network Security Learning (II) IP address
Outlook邮件创建的规则失效,可能的原因
I'd like to ask if the table creation DDL of ODPs can't be directly executed in MySQL. The string type is incompatible. Can you only adjust this by yourself
Some analysis of slow MySQL query
Shell调试Debug的三种方式