Summarize common interview questions of concurrent programming

Hello, hello, I am Dabai (●—●)

Common interview questions for concurrent programming

  • What is the difference between a daemon thread and a user thread in Java?
  • The difference between threads and processes
  • What is context switching in multithreading
  • The difference between deadlock and livelock, the difference between deadlock and starvation?
  • Synchronized underlying implementation principle
  • What is a thread group and why is it not recommended in Java?
  • What is the Executors framework? Why use Executor framework
  • What is the difference between Executor and Executors in Java?
  • What is an atomic operation? What are the atomic classes in the Java Concurrency API?
  • What is the Lock interface in the Java Concurrency API? What are its advantages over synchronized?

  • What is a blocking queue? What is the realization principle of blocking queue? How to use blocking queues to implement the producer-consumer model?
  • What are Callable and Future?
  • What is FutureTask?
  • What is the implementation of concurrent containers?
  • There are several ways to achieve multi-thread synchronization and mutual exclusion, what are they?
  • What is a race condition?
  • Why do we execute the run() method when we call the start() method, why can’t we call the run() method directly?
  • What is the difference between CycliBarriar and CountDownLatch in Java?
  • What is an immutable object, and how does it help concurrent applications?
  • What is the difference between notify() and notifyAll()?

  • What is a reentrant lock (ReentrantLock)? Talk about its implementation.
  • When a thread enters a synchronized instance method of an object, can other threads enter other methods of this object?
  • The understanding of optimistic lock and pessimistic lock and how to realize it, what are the ways to realize it?
  • What is CAS operation and what are the disadvantages?
  • What is the difference between SynchronizedMap and ConcurrentHashMap?
  • What application scenarios can the copy-on-write container be used for?
  • What is the use of volatile? Can you explain the application scenarios of volatile in one sentence?
  • Why does the code reorder?
  • The difference between wait and sleep method in java?
  • What happens if an exception occurs when a thread is running?

  • Why are the wait, notify and notifyAll methods not in the thread class?
  • What is ThreadLocal variable
  • What is the difference between interrupted and isInterrupted methods in Java?
  • Why should the wait and notify methods be called in a synchronized block?
  • Why should you check the wait condition in the loop?
  • How to detect whether a thread owns a lock?
  • How do you get the thread stack in Java?
  • What is the difference between the submit() and execute() methods in the Java thread pool?
  • What is your understanding of thread priority?
  • How do you ensure that the thread where the main() method is located is the thread where the Java program ends last?

  • Why are the sleep() and yield() methods of the Thread class static?
  • Now there are three threads T1, T2, and T3. How do you ensure that T2 is executed after T1 is executed, and T3 is executed after T2 is executed?
  • You need to implement an efficient cache, which allows multiple users to read, but only allows one user to write, in order to maintain its integrity, how would you implement it?
  • Implement blocking queue in Java
  • Write code in Java to solve the producer-consumer problem.
  • Write a program in Java that will cause a deadlock, how do you solve it?
  • How to stop a thread in Java?
  • Which parameter in the JVM is used to control the stack size of the thread?
  • What happens if a thread in a synchronized block throws an exception?

  • What is the double check implementation of the singleton pattern? Why is it not safe? How to create a thread-safe Singleton in Java?
  • Write 3 best practices for multithreading that you follow
  • Please outline the creation parameters of the thread pool, how to configure the parameters of a thread pool reasonably?
  • Please outline the fairness and unfairness of locks and how they are implemented in the JDK.
  • Please outline AQS
  • Please outline Volatile

Dabai (●—●) accompany you to make progress together!
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_42292697/article/details/112676567