Summary of questions about multithreading and high concurrency in Java position interviews

2023/04/02 1:28

  1. What kind of locks does java have? Have you used reentrantlock? The difference between reentrantlock and syncmchronized
  2. Why use a lock?
  3. Use a mutex to implement a read-write lock, with priority given to writers
  4. Corresponding wait and notify in reentrant lock
  5. Reentrant read-write lock, how is reentrancy achieved?
  6. The usage scenarios of ThreadLocal and the problems to be paid attention to when using it
  7. For an ordinary thread pool, coreSize = 5, maxSize = 10, the length of the blocking queue is 20, and the insertion thread is executed permanently, then how about the number of threads in the thread pool and the corresponding response to the continuous insertion of threads? ?
  8. Several ways to create threads
  9. Basic principles of lock implementation
  10. The difference between lock and try lock in reentrant lock
  11. How to make a distributed lock
  12. The difference between runnable and callable
  13. In the java thread pool, the two thread pools based on cache and based on fixed length, how do they deal with too many requests? The fixed-length queue is used. What if the queue is also full? Swap into disk? What about cache-based thread pool solutions?
  14. Thread pool (7 core parameters of ThreadPoolExecutor, 4 rejection strategies, 1 usage principle)
  15. Which thread pools have been used, their principles are briefly summarized, the meaning of each parameter of the constructor, such as coreSize, maxsize, etc., and what determines the maximum number of threads in the thread pool
  16. Thread pool parameter settings, why are they set up like this, and what is the effect? 7 major parameters
  17. Have you used spring thread pool or java thread pool?
  18. For an ordinary thread pool, coreSize = 5, maxSize = 10, the length of the blocking queue is 20, and the insertion thread is executed permanently, then how about the number of threads in the thread pool and the corresponding response to the continuous insertion of threads? ?
  19. The difference between wait() and sleep() methods. And the implementation principle of wait
  20. Thread blocking method
  21. The state of the thread
  22. What is thread safety and what is reordering
  23. How does the thread exit and end
  24. What engine can be used for reading more and writing less?
  25. Why are the stop() and suspend() methods deprecated?
  26. What are the similarities and differences between synchronous and asynchronous, and under what circumstances should they be used?
  27. What kind of lock does synchronized add to the method? Do you understand the synchronized keyword?
  28. What optimizations did synchronized do in JDK6, the difference between synchronized and lock
  29. When a thread enters a synchronized method of an object, can other threads enter other methods of this object?
  30. Briefly describe the similarities and differences between synchronized and java.util.concurrent.locks.Lock? The principle of synchronized, what is spin lock, biased lock, lightweight lock, what is reentrant lock, what is fair lock and unfair lock
  31. Explain several available states of threads in general.
  32. The difference between run() and start(). Why does thread execution call start instead of run directly
  33. Please tell me the method of thread synchronization you know.
  34. Thread scheduling and thread control.
  35. What is thread starvation and what is livelock?
  36. What is busy loop in multithreading?
  37. What is a volatile variable? What is the difference between a volatile variable and an atomic variable?
  38. What guarantees do volatile type variables provide? Can a non-atomic operation be made atomic?
  39. Reordering of volatile instructions, memory barriers
  40. The principle and function of volatile, can it replace locks, the usage of volatile keyword, the use of volatile
  41. Which atomic classes have been used, what are their parameters and principles
  42. If you were asked to implement a concurrency-safe linked list, what would you do
  43. AQS principle (source code of execution process, details of enqueue and dequeue, source code details)
  44. The difference between lazy man style and hungry man style
  45. Is it thread-safe to use double check for lazy singletons? Why add volatile
  46. What is CAS?
  47. Implementation of optimistic locking in Java (CAS+spin)
  48. What is the happens before principle
  49. What does thread join mean
  50. What kinds of locks does Java have? There are several types of thread pools. Among them, coreSize, maxSize, survival time, waiting queue, and rejection strategy must be clear about the implementation of blocking queues. At least two methods of blocking queues can be implemented by yourself. method (single lock, multiple lock, ReentrantLock, Condition)
  51. Is HashMap thread-safe, how is it implemented at the bottom layer (get, set, resize), what changes have been made before and after JDK1.8, and which HashMap (LinkedHashMap, TreeMap, ), how is ConcurrentHashMap thread-safety implemented (different implementations before and after JDK1.8)
  52. Netty, Jetty implementation principle.
  53. Forkjoin model
  54. Java Callbacks

Leave a Reply

Back to top