当前位置:网站首页>Interview series 2: concurrent programming

Interview series 2: concurrent programming

2020-11-09 13:37:49 Zhaozhen

Concurrent programming

The use of multithreaded classes

  • java What are the methods of thread synchronization 、 Advantages and disadvantages of each
  • synchronized and ReentrantLock difference , What are reentrant locks ?
  • threadlocal What's the usage?
  • Java There are several ways to create threads in ? Namely ? When the main thread is finished executing , Will the child thread continue to execute ?
  • JUC What are the common collections in ?( Used in the project )
  • CopyOnWriteArrayList Implementation principle of ? What is the main application scenario ? The advantages and disadvantages are ?
  • HashMap Not thread safe , What happens when inserting in a high concurrency environment ? Why? ?
  • jdk1.8 before ConcurrentHashMap How to realize thread safety ?jdk1.8 Later? ?(1.8synchronized Add CAS, And introduced red and black trees )
  • When calling ConcurrentHashMap Of size When the method is used , There are elements inserted simultaneously ,ConcurrentHashMap How did you handle it ?
  • synchronized and java.util.concurrent.locks.Lock Comparison . AtomicInteger principle , Why use CAS instead of synchronized? In the back end of the bank, if many people want to have a large account , What's the problem ?
  • What is? CAS operation , How to implement a custom lock
  • Synchronized The implementation of the , Lock upgrade process .
  • AQS Do you understand ?
  • wait()、notify Under what circumstances must you use
  • Threads 、 process 、 The relationship between the processes .
  • Yes volatile The understanding of the
  • To be specific concurrentHashMap put technological process
  • How do you understand synchronization / asynchronous , Concurrent / Of the concept of parallelism
  • So talk about it Lock Interface API And its implementation class related understanding ?
  • that ReentrantLock Medium lock and unlock Synchronization between threads how to communicate between threads ?
  • Semaphore Class understanding ?
  • JUC The counting lock under the package ?CountDownLatch?
  • CyclicBarrier The understanding of the ?
  • ReadWriteLock And ReentrantReadWriteLock The understanding and difference of ?
  • You also know ReentrantReadWriteLock Which features ?
  • ReentrantLock How to realize fair and unfair lock ? CountDownLatch and CyclicBarrier The difference between ? What scenarios do they apply to ?
  • The difference between optimistic lock and pessimistic lock ? How to achieve an optimistic lock ?
  • AQS How to wake up the next thread ?
  • ConcurrentHashMap How to make multithreading participate in capacity expansion at the same time ?get Do you need to lock it , Why? ?
  • Disruptor Frame usage , Realization
  • Future How is the asynchronous call process of ?Future Overtime ? Infinite recursion causes jvm What's wrong with memory ?
  • Java8 After that ConcurrentHashMap Why abandon the block lock ?
  • A whole set of thread pools ( Implementation class and corresponding blocking queue 、 Refusal strategy 、 Specific parameters 、ScheduledThreadPool There are three ways to construct , What do they mean respectively ?)
  • synchronized Modify the instance method and static method respectively , Whether multi thread concurrency will compete for locks ?synchronized What's the difference between decorating methods and code blocks , How is the underlying implementation done ?
  • Producer consumer pattern code in concurrent programming .[ The easiest way is to use wait and notify To block the wake-up , Of course, you can also use reentrant locks (ReentrantLock), Use the lock counter (CountdownLatch) wait ]
  • Why use a read-write lock instead of synchronized This synchronization lock
  • How to control the thread to complete in a certain period of time , Cancel if you don't finish .
  • reference ConcurrentHashMap, If you use it in a multithreaded environment HashMap, Is there any way to improve efficiency and ensure thread safety ?
  • Yes Java Understanding of memory model , And its application in concurrency ; Instruction reordering , Memory fence, etc
  • Java What types of locks are available ?
  • What are the concurrent containers , The difference between concurrent containers and synchronous containers ?
  • CLH How do synchronous queues achieve unfairness and fairness ?
  • HashMap In high concurrency, what are the security risks if you don't deal with thread security , What is the specific performance .
  • Lock What implementation classes do interfaces have , What is the usage scenario .
  • The use and implementation principle of reentrant lock , The process of copying while writing , Read-write lock , Section lock (ConcurrentHashMap Medium segment)
  • CountDown Have you ever understood ?CountDown and CycliBarrier What's the difference between ? What's the difference in use ?
  • volatile Reorder from instructions , Memory barrier , Talking about the bus storm
  • Asked how to share data between parent and child threads
  • List It's not thread safe , How do you make it thread safe ?
  • synchronized Can I run other threads while running the current thread
  • What is guard thread , How to implement the guardian thread ? How to stop a thread ?
  • Concurrent programming is very detailed . Then multiple threads are executed together , After reaching a certain state, the concurrent execution will continue , How to achieve this ?
  • How to control the thread to complete in a certain period of time , Cancel if you don't finish
  • How to avoid writing thread starvation after adding read lock to read-write lock
  • Some principles of thread pool , Lock mechanism lifting stage
  • What's the way spinlock works Ask whether the address the pointer points to is a virtual address or a physical address . What are the algorithms of page table replacement , And now which algorithm is more efficient . Ask the process of page missing exception replacement . If a thread modifies a data , But at this time, you need to replace the current page table , How does the operating system handle .
  • The difference between a process and a thread , How to determine the maximum number of threads you create based on your hardware ( Thread pools need to consider )

Thread pool

  • Thread pool When to reach the maximum number of threads Performance that continues to commit after reaching the maximum thread What locks have you used
  • What are the core parameters of thread pool ? Briefly describe the principle of thread pool ?
  • How to create a thread pool ?
  • Thread pool thread submission method and advantages and disadvantages .
  • If we use unbounded queues in the thread pool, what's the impact ?
  • Multiple core threads go to take Blocking threads in the queue , Who can get it ?
  • How does thread pool realize reusing threads
  • JDK Medium bias lock 、 spinlocks 、 Lightweight lock 、 The difference between heavyweight locks ? JDK Do you know the spin threshold of lock spin ? How to adjust the spin number ?
  • Why do you use thread pool when placing orders in your system ? Can you use other implementations ?

Extension of multithreading

  • Distributed lock zookeeper Usage scenarios of ------ How to implement distributed locks ----------redis Distributed locks and zookeeper Distributed lock
  • How do you handle high concurrency scenarios , For example, the mall second kill ?
  • Database concurrency strategy
  • How to limit flow when concurrency is high
  • Scene simulation : So let's say I have a scenario , The system needs to respond to user requests within a certain period of time , for instance 100ms Complete user request in , But at its peak, millions of user requests per unit of time , High concurrency , But I have to make the system respond in time , And high availability , If you are an architect , How do you structure this system , Talk about your plan .
  • Thread programming : Write two threads , Add data to an array , A subtraction of data from an array , Ask for data that doesn't cross the line . In fact, it is the production of consumers
  • How to design seckill system ?
  • If a deadlock occurs while processing concurrency ?
Welcome to search and pay attention to the wechat face-to-face program developed by me and friends 【 Interview assistant of big factory 】 And the official account 【 Micro view technology 】

版权声明
本文为[Zhaozhen]所创,转载请带上原文链接,感谢