Interview Question Bank (5): Concurrent Programming

Use of multi-threaded classes

  • What are the methods of java thread synchronization and their respective advantages and disadvantages?
  • What is the difference between synchronized and ReentrantLock? What is a reentrant lock?
  • What is the use of threadlocal?
  • How many ways are there to create threads in Java? What are the differences? When the main thread ends, will the sub-thread continue to execute?
  • What are the commonly used collections in JUC? (used in the project)
  • How does CopyOnWriteArrayList implement? What are the main application scenarios? What are the advantages and disadvantages?
  • HashMap is not thread-safe. What will happen when inserting in a high-concurrency environment? Why?
  • How did ConcurrentHashMap achieve thread safety before jdk1.8? What about after jdk1.8? (1.8synchronized plus CAS, and introduced red-black tree)
  • When the size method of ConcurrentHashMap is called, elements are inserted concurrently. How does ConcurrentHashMap handle it?
  • Comparison of synchronized and java.util.concurrent.locks.Lock. AtomicInteger principle, why use CAS instead of synchronized? What problems will the bank's backend encounter if multiple people want to make a lot of money in one account?
  • What is CAS operation,

Guess you like

Origin blog.csdn.net/cq20110310/article/details/133187568