Recently preparing for the interview of friends can pay attention to my column – help autumn recruit, I hope to help you
Systematic combing of knowledge system
Related information Sharing
- Summary of Java basic knowledge
- 2021 Gold three silver four Java post interview summary
- First-line Internet company Java interview core knowledge points
The foundation of Java concurrency
A. Java Advanced – Java Concurrency basics: First of all, understand the knowledge system of concurrency, concurrency theory and threading, concurrency keywords, etc., these are the foundation of your understanding of Java concurrency framework. @pdai
-
Java Concurrency – Body of knowledge
-
Java concurrency – Fundamentals of theory
-
What problem is the emergence of multithreading to solve?
-
What do I mean by thread unsafe? For example
-
What is the nature of concurrent thread insecurity? Visibility, atomicity, and orderliness.
-
How does Java solve the concurrency problem? 3 keywords, JMM and 8 happens-before
-
Is thread safety either true or false? not
-
What are the implementation ideas for thread safety?
-
How to understand the difference between concurrency and parallelism?
-
Java concurrency – Threading basics
-
What states does a thread have? What are the ways of changing from one state to another?
-
What are the common ways threads are used?
-
What are the underlying threading mechanisms?
-
What are the ways to interrupt a thread?
-
What are the mutually exclusive synchronization methods for threads? How to compare and choose?
-
What are the ways threads collaborate?
Concurrency keywords: volatile, final, synchronized
-
Keywords: synchronized detailed explanation
-
Where does Synchronized work? Object locking and class locking are used as examples respectively.
-
What does Synchronized essentially do to ensure thread safety? The answer is divided into three aspects: the principle of locking and locking release, the principle of reentrant, the principle of ensuring visibility.
-
What are the defects of Synchronized? How Java Lock addresses these shortcomings.
-
Contrast and choose between Synchronized and Lock?
-
What should be paid attention to when using Synchronized?
-
Do Synchronized modified methods release locks when they throw exceptions?
-
When multiple threads are waiting for the same Snchronized lock, how does the JVM select the next thread to acquire the lock?
-
Synchronized causes only one thread to execute at the same time, and its performance is poor. Is there any method to improve Synchronized?
-
I want to have more flexible control over lock release and acquisition (now the lock release and acquisition times are specified), what should I do?
-
What are lock upgrades and downgrades? What are bias locks, lightweight locks, and heavyweight locks in the JVM?
-
What are the optimizations for Synchronized in different JDKS?
-
Keyword: volatile detailed explanation
-
What does the volatile keyword do?
-
Does volatile guarantee atomicity?
-
Why volatile for long and double variables previously shared on 32-bit machines? Do I need to do this on 64-bit machines now?
-
Why doesn’t i++ guarantee atomicity?
-
How does volatile achieve visibility? Memory barriers.
-
How does volatile achieve order? Happens-before, etc
-
What is the use of volatile?
-
Key word: final detail
-
Are all final modified fields compile-time constants?
-
How to understand that a method modified by private is implicitly final?
-
How can classes of final type be extended? For example, if String is final and we want to write a MyString method that reuses all the methods in String and adds a new toMyString() method, what should we do?
-
Can final methods be overridden? can
-
Can a final method of a parent class be overridden by a subclass? Can not be
-
What about final field reordering?
-
How does final work?
-
What are the limitations and limitations of using final?
-
Look at a question at the end of this article
J.U.C framework
Lock framework and Tools classes
Class structure overview
Interface: Condition
Condition is an interface type that breaks the Object monitor methods (WAIT, notify, and notifyAll) into distinct objects in order to provide multiple wait sets (wait-sets) for each Object by combining these objects with any Lock implementation. Lock replaces the use of synchronized methods and statements, and Condition replaces the use of Object monitor methods. The thread can sleep/wake up with await(),signal().
In JUC lock: AbstractQueuedSynchonizer explanation of inner classes – conditionobject class has a specific analysis.
Interface: the Lock
Lock is the interface type, and the Lock implementation provides a broader range of locking operations than can be obtained using synchronized methods and statements. This implementation allows for a more flexible structure, can have very different attributes, and can support multiple related Condition objects.
Interface: ReadWriteLock
ReadWriteLock is an interface type that maintains a pair of associated locks, one for read-only operations and the other for write operations. As long as there is no writer, the read lock can be held by multiple reader threads simultaneously. The write lock is exclusive.
Abstract: AbstractOwnableSynchonizer
AbstractOwnableSynchonizer as an abstract class, can be owned by thread in exclusive mode of synchronizer. This class provides the basis for creating locks and associated synchronizers (along with the concept of ownership). AbstractOwnableSynchronizer class itself does not manage or use this information. However, subclasses and tools can help control and monitor access and provide diagnostics with properly maintained values.
An abstract class (long) : AbstractQueuedLongSynchronizer
AbstractQueuedLongSynchronizer as an abstract class, in the form of long maintain a AbstractQueuedSynchronizer version of the sync. Such a structure, properties and methods with AbstractQueuedSynchronizer are exactly the same, but all the state related parameters and results are defined as long not int. This class is useful when creating synchronizers such as multilevel locks and barriers that require 64-bit state.
Core classes (int) : AbstractQueuedSynchonizer
AbstractQueuedSynchonizer abstract class, its to implement depends on the first-in, first-out (FIFO) waiting queue blocking locks and related synchronizer (semaphore, events, etc.) to provide a framework. The design goal of this class is to be a useful foundation for most synchronizers that rely on a single atomic INT value to represent state.
Please see detailed analysis: JUC lock: AbstractQueuedSynchonizer explanation
Lock common class: LockSupport
LockSupport is a common class used to create a basic thread blocking primitive for locks and other synchronization classes. LockSupport is similar to thread.suspend () and thread.resume () in that park() and unpark() in LockSupport block and unblock threads, respectively. But park() and unpark() do not encounter the “deadlocks that may be caused by Thread.suspend and thread.resume” problem.
For detailed analysis, please see: JUC lock: LockSupport
Lock common class: ReentrantLock
A common class, ReentrantLock, is a reentrant mutex Lock that has some of the same basic behavior and semantics as implicit monitor locks accessed using synchronized methods and statements, but is more powerful.
JUC lock: ReentrantLock
Common lock class: ReentrantReadWriteLock
ReentrantReadWriteLock is an implementation class of ReadWriteLock, which includes the Lock subclasses ReadLock and WriteLock. ReadLock is a shared lock, and WriteLock is an exclusive lock.
For details, see: JUC tool class: ReentrantReadWriteLock
Common lock classes: StampedLock
It is java8 in Java. Util. Concurrent. The locks a new API. StampedLock control lock has three modes (write, read, optimistic read). A StampedLock status is composed of two parts: version and mode. The lock acquisition method returns a number as stamp, which represents and controls access with the corresponding lock status. Read locks are divided into pessimistic locks and optimistic locks.
For details, see Java 8-StampedLock
Common tool class: CountDownLatch
CountDownLatch is the common class. It is a synchronization helper class that allows one or more threads to wait until a set of operations that are being performed in other threads are complete.
For detailed analysis, see: JUC tool class: CountDownLatch
Common class for tools: CyclicBarrier
CyclicBarrier is a common class that is a synchronization helper that allows a group of threads to wait for each other until a common barrier point is reached. Cyclicbarriers are useful in programs that involve a set of threads of a fixed size that must wait for each other from time to time. Because this barrier can be reused once the waiting thread is freed, it is called a cyclic barrier.
For a detailed analysis, see: JUC tool class: CyclicBarrier
Common tool class: Phaser
Phaser is a synchronization helper class added to JDK 7 that implements features like CyclicBarrier and CountDownLatch, and it supports dynamic adjustment of tasks and hierarchical structure for higher throughput.
See: JUC Tool Class: Phaser for more details
Common tool class: Semaphore
Semaphore, the common class, is a counting Semaphore that conceptually maintains a license set. If necessary, each acquire() is blocked until the license is available, and then the license is obtained. Each release() adds a license, possibly freeing a blocking acquirer. However, instead of using actual license objects, Semaphore only counts the number of licenses available and acts accordingly. Usually used to limit the number of threads that can access certain resources (physical or logical).
For detailed analysis, see: JUC tool class: Semaphore
Common tool: San_recovery
Sanorecovery is a tool used for thread collaboration, mainly for data exchange between two threads. It provides a synchronization point at which two threads can exchange data with each other. The two threads exchange data using the Exchange () method. When one thread executes the Exchange () method first, it waits until the second thread executes the exchange() method. When the two threads reach the synchronization point, the two threads can exchange data.
For detailed analysis, see JUC tool: San_recovery
Collections: Concurrent Collections
Class structure relation
Queue: ArrayBlockingQueue
A bounded blocking queue supported by arrays. This queue sorts elements on a FIFO(first-in, first-out) basis. The header of the queue is the element that has been in the queue for the longest time. The end of the queue is the element that has been in the queue for the shortest time. The new element is inserted at the end of the queue, and the queue fetch operation retrieves the element from the head of the queue.
JUC concurrent Collection: BlockingQueue
Queue: LinkedBlockingQueue
A blocking queue of arbitrary scope based on linked nodes. This queue sorts elements in FIFO(first in, first out). The head of the queue is the element that has been in the queue for the longest time. The end of the queue is the element that has been in the queue for the shortest time. The new element is inserted at the end of the queue, and the queue fetch operation retrieves the element at the head of the queue. Linked queues typically have higher throughput than array-based queues, but lower predictable performance in most concurrent applications.
JUC concurrent Collection: BlockingQueue
Queue: LinkedBlockingDeque
An optional range of blocking double-endian queues based on linked nodes.
JUC concurrent Collection: BlockingQueue
Queue: ConcurrentLinkedQueue
An unbounded thread-safe queue based on linked nodes. This queue sorts elements according to FIFO(first in, first out). The head of the queue is the longest element in the queue. The tail of the queue is the element with the shortest time in the queue. The new element is inserted at the end of the queue, and the queue fetch operation retrieves the element from the queue head. ConcurrentLinkedQueue is an appropriate choice when multiple threads share access to a common collection. This queue does not allow null elements.
JUC concurrent collection: ConcurrentLinkedQueue
Queue: ConcurrentLinkedDeque
Is an unbounded queue implemented by a bidirectional list, which supports BOTH FIFO and FILO.
Queue: DelayQueue
Delay unbounded blocking queue, using the Lock mechanism to achieve concurrent access. Only elements that can be “extended” are allowed in the queue, with the head being the first element to “expire”. If there are no elements in the queue that are “due”, they cannot be retrieved even if there are elements in the queue.
Queue: PriorityBlockingQueue
Unbounded priority blocking queues, using the Lock mechanism for concurrent access. A thread-safe version of priorityQueue that does not allow null values, relies on Comparable sorts, and does not allow non-comparable object types to be stored.
Queue: SynchronousQueue
Synchronous queue without capacity, concurrent access through CAS, SUPPORT FIFO and FILO.
Queue: LinkedTransferQueue
New in JDK 7, unidirectional linked list implementation of unbounded blocking queue, CAS implementation of concurrent access, queue elements using FIFO(first-in, first-out) mode. The LinkedTransferQueue is a superset of ConcurrentLinkedQueue, SynchronousQueue, and LinkedBlockingQueue. It not only combines the functionality of these classes, but also provides a more efficient implementation.
List: CopyOnWriteArrayList
A thread-safe variant of ArrayList, where all mutable operations (add, set, and so on) are implemented by making a new copy of the underlying array. This is generally expensive, but it can be more efficient than other alternatives when the number of traversal operations greatly exceeds the number of mutable operations. It is also useful when synchronous traversal is not possible or desirable, but conflicts need to be eliminated from concurrent threads.
JUC concurrent collection: CopyOnWriteArrayList
Set: CopyOnWriteArraySet
Use the Set of the internal CopyOnWriteArrayList for all of its operations. Forwarding all operations to CopyOnWriteArayList for operation is thread-safe. AddIfAbsent is called when you add, and the performance is slightly lower than CopyOnWriteArrayList due to array traversal every time you add.
Set: ConcurrentSkipListSet
A scalable concurrent NavigableSet implementation based on ConcurrentSkipListMap. The elements of a set can be sorted according to their natural order or according to the Comparator provided when the set was created, depending on the constructor used.
Map: ConcurrentHashMap
Thread-safe HashMap. ConcurrentHashMap was implemented using Lock and segment before JDK 7, and CAS+synchronized after JDK 8 to ensure concurrency security.
JUC concurrent Collection: ConcurrentHashMap contains source code analysis for JDK 7 and JDK 8 versions.
Map: ConcurrentSkipListMap
Thread-safe ordered hash tables (equivalent to thread-safe TreeMap); Depending on the constructor used, the mapping can be sorted according to the natural order of the keys or by the Comparator provided when the mapping is created.
Atomic: Atomic classes
The basic feature is that in a multithreaded environment, when multiple threads execute the methods contained in the instance of these classes at the same time, it has exclusivity. That is, when one thread enters the method and executes its instructions, it will not be interrupted by other threads, while other threads, like spinlocks, wait until the method completes. It is only logical that the JVM selects one thread from the wait queue to enter another. This is actually done by means of hardware instructions that do not block threads (or just at the hardware level).
For details on the CAS, Unsafe, and 13 atomic classes, see: JUC atomic Classes: CAS, Unsafe, and the Unsafe atomic class
Base types: AtomicBoolean, AtomicInteger, AtomicLong
AtomicBoolean, AtomicInteger, and AtomicLong are similar for bool, interger, and long atomic classes respectively.
Arrays: AtomicIntegerArray, AtomicLongArray, BooleanArray
AtomicIntegerArray, AtomicLongArray, AtomicBooleanArray are array atom classes.
References: AtomicReference, AtomicMarkedReference, AtomicStampedReference
AtomicReference, AtomicMarkedReference, and AtomicStampedReference are the atomic classes associated with the reference.
FieldUpdater: AtomicLongFieldUpdater AtomicIntegerFieldUpdater, AtomicReferenceFieldUpdater
AtomicLongFieldUpdater AtomicIntegerFieldUpdater, AtomicReferenceFieldUpdater is FieldUpdater atomic classes.
Executors: thread pool
Class structure relation
Interface: Executor
The Executor interface provides a way to separate task submission from the mechanics of how each task will run, including details of thread usage, scheduling, and so on. Threads are usually created using executors rather than explicitly.
ExecutorService
ExecutorService inherits from the Executor interface, and provides a way to manage terminations, as well as a way to generate futures for tracking the execution of one or more asynchronous tasks. You can shut down the ExecutorService, which causes it to stop accepting new tasks. When closed, the execution program terminates, with no tasks running, no tasks waiting to be executed, and no new tasks can be submitted.
ScheduledExecutorService
ScheduledExecutorService Is a command inherited from the ExecutorService interface that can be scheduled to run or execute periodically after a given delay.
AbstractExecutorService
AbstractExecutorService inherits from the ExecutorService interface, which provides a default implementation of the ExecutorService execution method. This class implements the submit, invokeAny, and invokeAll methods using the RunnableFuture returned by newTaskFor. By default, RunnableFuture is the FutureTask class provided with this package.
FutureTask
FutureTask provides basic implementations for Future, such as getting task execution results (GET) and canceling tasks (cancel). If the task has not completed, obtaining the execution result of the task will be blocked. Once the execution is complete, the task cannot be restarted or cancelled (unless calculations are performed using runAndReset). FutureTask is often used to encapsulate Callable and Runnable, or it can be submitted to a thread pool for execution as a task. In addition to being a separate class, this class also provides some functional functions that you can use to create custom Task classes. The thread safety of FutureTask is guaranteed by CAS.
See JUC Thread Pool: FutureTask for details
Core: ThreadPoolExecutor
ThreadPoolExecutor implements the AbstractExecutorService interface and is an ExecutorService that executes each submitted task using one of several possible pool threads, usually configured using the Executors Factory method. Thread pools solve two different problems: they typically provide increased performance when performing a large number of asynchronous tasks because of the reduced overhead per task invocation, and they also provide a way to bind and manage resources, including the threads used when executing the task set. Each ThreadPoolExecutor also maintains some basic statistics, such as the number of tasks completed.
JUC thread Pool: ThreadPoolExecutor
Core: ScheduledThreadExecutor
ScheduledThreadPoolExecutor ScheduledExecutorService interface, can be arranged in a given delay running commands, or execute the command on a regular basis. This class is superior to a Timer when multiple worker threads are required, or when ThreadPoolExecutor is required to have additional flexibility or functionality.
JUC thread pool: ScheduledThreadExecutor
Core: Fork/Join framework
ForkJoinPool is a thread pool class added to JDK 7. Fork/Join is a parallel implementation of divide-and-conquer algorithm. It is a simple and efficient design technique that can achieve good parallel performance. The goal is to help us take advantage of the benefits of multiprocessors, using all the computing power available to improve the performance of our applications.
JUC thread pool: Fork/Join framework
Tools: Executors
Executors is a tool class that allows you to create ExecutorService, ScheduledExecutorService, ThreadFactory, and Callable objects. Its use is incorporated into ThreadPoolExecutor, ScheduledThreadExecutor, and ForkJoinPool.
J.U.C. Frame key interview questions in detail
B. Java Advanced – Java concurrency J.U.C framework: Then you need a detailed interpretation of the J.U.C framework’s five classes, including: Lock framework, concurrency sets, atomic classes, thread pools, and utility classes. @pdai
-
JUC – Class summary and study guide
-
How many parts does the JUC framework consist of?
-
What are the core classes for each section?
-
What are the core classes?
J.U.C framework [1/5] : CAS and atomic classes
B.1 Java Advanced – Java Concurrency framework [1/5] : CAS and Atomic Classes: Start with the core CAS, Unsafe, and atomic classes.
-
JUC atomic classes: CAS, Unsafe and unexplored atomic classes
-
What are the ways to implement thread-safe?
-
What is CAS?
-
CAS uses examples, combined with AtomicInteger to give examples?
-
What are the problems with CAS?
-
What solutions does Java provide to these problems?
-
AtomicInteger underlying implementation? CAS+volatile
-
What do you understand about the Unsafe class?
-
What do you understand about Java atomic classes? Contains 13, 4 groups of classification, talk about the role and use scenarios.
-
What is an AtomicStampedReference?
-
How does AtomicStampedReference solve ABA? Internally, pairs are used to store element values and their version numbers
-
What other classes in Java can solve the ABA problem? AtomicMarkableReference
J.U.C. frame [2/5] : Lock
B.2 Java advanced – Java concurrency J.U.C framework [2/5] : locking: then analyze the locking in JUC.
-
JUC lock: LockSupport
-
Why is LockSupport also a core base class? The AQS framework relies on two classes: Unsafe(for CAS operations) and LockSupport(for park/unpark operations)
-
Park /unpark with wait/notify and LockSupport respectively
-
Does locksupport.park () release lock resources? What about condition.await ()?
-
Thread.sleep(), object.wait (), condition.await (), locksupport.park ()? Focus on
-
What if notify() was executed before wait()?
-
What if unpark() was executed before park()?
-
JUC lock: lock core AQS details
-
What is AQS? Why is it central?
-
What is the core idea of AQS? How does it work? Underlying data structures, etc
-
What are the core methods of AQS?
-
What does AQS define for resource acquisition? AQS defines two methods of resource acquisition: Exclusive (only one thread can access the execution, and it is divided into fair and unfair locks, such as ReentrantLock, based on queue order) and shared (multiple threads can access the execution simultaneously, such as Semaphore, CountDownLatch, and CyclicBarrier). ReentrantReadWriteLock can be viewed as a composite that allows multiple threads to read a resource simultaneously.
-
What design patterns are used at the bottom of AQS? The template
-
Examples of AQS?
-
JUC lock: ReentrantLock
-
What is reentrant and what is reentrant lock? What problem does it solve?
-
The core of ReentrantLock is AQS, so how does it implement, inheritance? Talk about the class internal structure relationships.
-
How does ReentrantLock implement fair locking?
-
How does ReentrantLock implement unfair locking?
-
Does ReentrantLock implement fair or unfair locking by default?
-
Examples of fair and unfair locking using ReentrantLock?
-
ReentrantLock vs. Synchronized?
-
JUC lock: ReentrantReadWriteLock
-
In order to have ReentrantLock you also need ReentrantReadWriteLock?
-
How is ReentrantReadWriteLock implemented?
-
How is ReentrantReadWriteLock designed? The high 16 bits are read locks, and the low 16 bits are write locks
-
What is the maximum number of read and write locks?
-
What is the local thread counter ThreadLocalHoldCounter used for?
-
What does the cache counter HoldCounter do?
-
How is the acquisition and release of write locks implemented?
-
How are read locks acquired and released?
-
Why does RentrantReadWriteLock not support lock upgrade?
-
What is the upgrade and downgrade of locks? Why does RentrantReadWriteLock not support lock upgrade?
J.U.C framework [3/5] : Collections
B.3 Java Advancements – The J.U.C. framework for Java concurrency [3/5] : Collections: Reunderstand the important collections in JUC that support concurrency.
-
JUC collection: ConcurrentHashMap details
-
Why is HashTable slow? What is its concurrency? So what’s the ConcurrentHashMap concurrency?
-
What is the real difference between the ConcurrentHashMap in JDK1.7 and JDK1.8? What problem does JDK1.8 solve in JDK1.7
-
What is the implementation principle of ConcurrentHashMap JDK1.7? Segmental locking mechanism
-
What does ConcurrentHashMap JDK1.8 implement? Array + linked list + red black tree, CAS
-
ConcurrentHashMap JDK1.7 What is the default value of Segment number (concurrencyLevel)? Why is it impossible to expand once initialized?
-
ConcurrentHashMap JDK1.7
-
How to expand ConcurrentHashMap JDK1.7? HashEntry<K,V>[]
-
How to expand ConcurrentHashMap JDK1.8? tryPresize
-
ConcurrentHashMap JDK1.8 what is the timing of the list to red black tree? Why is the threshold 8?
-
How does ConcurrentHashMap JDK1.8 migrate data? transfer
-
JUC collection: CopyOnWriteArrayList details
-
Can you start with fail-fast for non-concurrent sets?
-
Why is ArrayList fast to query and slow to add and delete?
-
How does CopyOnWriteArrayList add, delete, change and check? COW based on copy
-
What about the weakly consistent iterator principle? COWIterator
-
Why is CopyOnWriteArrayList concurrency safe and better than Vector?
-
What are the drawbacks of CopyOnWriteArrayList?
-
JUC collection: ConcurrentLinkedQueue
-
What are the options for using thread-safe queues? Vector, the Collections. SynchronizedList (the List < T > List), ConcurrentLinkedQueue, etc
-
ConcurrentLinkedQueue Implementation data structure?
-
The underlying principle of ConcurrentLinkedQueue? Lock-free throughout (CAS)
-
What are the core methods of ConcurrentLinkedQueue? Offer (), poll(), peek(), isEmpty() and other common queue methods
-
How about the design of ConcurrentLinkedQueue HOPS(delayed update policy)?
-
What usage scenarios are suitable for ConcurrentLinkedQueue?
-
JUC collection: BlockingQueue
-
What is BlockingDeque?
-
What is the BlockingQueue family? ArrayBlockingQueue, DelayQueue, LinkedBlockingQueue, SynchronousQueue…
-
What scenarios is BlockingQueue suitable for?
-
BlockingQueue common method?
-
What are the BlockingQueue insertion methods? What is the difference between these methods (add(O),offer(o), Put (O),offer(O, timeout, timeUnit))?
-
How does BlockingDeque relate to BlockingQueue and compare their methods?
-
What situations does BlockingDeque work in?
-
What is the BlockingDeque family?
-
BlockingDeque and BlockingQueue?
J.U.C framework [4/5] : Thread pools
B.4 Java advanced – Java concurrency J.U.C framework [4/5] : thread pool: also analyze the thread pool used in JUC, etc.
-
JUC thread pools: FutureTask details
-
What problem is FutureTask designed to solve? Why?
-
What are the FutureTask class structure relationships?
-
What is the thread safety of FutureTask guaranteed by?
-
FutureTask result return mechanism?
-
Changes to the internal health of FutureTask?
-
How is FutureTask usually used? Give an example.
-
JUC thread pool: ThreadPoolExecutor
-
Why do we have thread pools?
-
What are the ways in which Java implements and manages thread pools? Please give a simple example of how to use it.
-
Why aren’t many companies allowed to use Executors to create thread pools? So how do you recommend using it?
-
What are the core configuration parameters of ThreadPoolExecutor? Please briefly explain
-
What are the three thread pools that ThreadPoolExecutor can create?
-
What happens when the queue is full and the number of workers reaches maxSize?
-
What RejectedExecutionHandler policies does ThreadPoolExecutor have? What is the default policy?
-
What is the thread pool task execution mechanism? Execute – > addWorker – >runworker (getTask)
-
How are tasks submitted in the thread pool?
-
How are tasks closed in a thread pool?
-
What configuration factors need to be considered when configuring a thread pool?
-
How do I monitor the state of the thread pool?
-
JUC thread pool: ScheduledThreadPool details
-
ScheduledThreadPoolExecutor to solve the problem of what kind of?
-
What are the characteristics of ScheduledThreadPoolExecutor ThreadPoolExecutor compared?
-
ScheduledThreadPoolExecutor what kind of data structure, core inner classes and abstract class?
-
What are the two closed strategy ScheduledThreadPoolExecutor? What’s the difference?
-
What is the difference between ScheduledThreadPoolExecutor scheduleAtFixedRate and scheduleWithFixedDelay?
-
Why ThreadPoolExecutor adjustment strategy, but does not apply to ScheduledThreadPoolExecutor?
-
Executors provides several methods to construct ScheduledThreadPoolExecutor?
-
JUC thread pooling: the Fork/Join framework
-
What kind of problems are Fork/Join used to solve?
-
In which JDK version was the Fork/Join framework introduced?
-
What are the three main modules of the Fork/Join framework? What is the relationship between modules?
-
ForkJoinPool class inheritance?
-
ForkJoinTask Abstract class inheritance? In practice, we typically inherit RecursiveTask, RecursiveAction, or CountedCompleter to implement our business requirements, rather than directly inheriting ForkJoinTask.
-
How does the Fork/Join framework work?
-
How to steal a Fork/Join
-
What JDK source code uses the Fork/Join idea?
-
How do I create a ForkJoinPool using the Executors Tools?
-
ForkJoin 1+2+3+… + 100000?
-
What are the considerations when using Fork/Join? In combination with the JDK Fibonacci sequence of examples.
J.U.C Framework [5/5] : Tool classes
B.5 Java Advancements – Java Concurrency J.U.C. framework [5/5] : Utility classes: Finally, take a look at what utility classes are available in JUC and the thread isolation ThreadLocal.
-
JUC tool class: CountDownLatch
-
What is CountDownLatch?
-
How does CountDownLatch work?
-
How many tasks can CountDownLatch wake up at once? multiple
-
What are the main methods of CountDownLatch? await(),countDown()
-
What scenarios does CountDownLatch work for?
-
Thread 1 adds 10 elements to the container. Thread 2 monitors the number of elements. When the number reaches 5, thread 2 gives a hint and terminates. Use CountDownLatch instead of Wait Notify.
-
CyclicBarrier: The JUC tool class
-
What is a CyclicBarrier?
-
How does CyclicBarrier work?
-
CountDownLatch versus CyclicBarrier?
-
What are the core functions of CyclicBarrier?
-
What scenarios does CyclicBarrier apply to?
-
JUC tool class: Semaphore details
-
What is Semaphore?
-
Semaphore’s inner workings?
-
What are the common methods of Semaphore? How to achieve thread synchronization and mutual exclusion?
-
Where does Semaphore fit in?
-
– Semaphore alone will not use AQS conditional queue?
-
Semaphore’s implementation of acquire and release tokens
-
What happens if Semaphore initializes with 10 tokens and 11 threads each call acquire method once?
-
What happens if Semaphore initializes with 10 tokens and a thread calls acquire method 11 times?
-
Semaphore initializes with 1 token, 1 thread calls acquire once, then releases twice, and then another thread calls Acquire (2). Can this thread get enough tokens and continue?
-
Semaphore initializes with 2 tokens. A thread calls release once and gets 3 tokens at once. Will it get them?
-
JUC tool classes: Phaser details
-
What problem is Phaser designed to solve?
-
What is the difference between phasers and cyclicbarriers and countdownlatches?
-
How do YOU implement Phaser functions using CountDownLatch?
-
How does Phaser work?
-
Give an example of Phaser use?
-
JUC tool: San_recovery
-
Which problem is the major solution?
-
Compared to SynchronousQueue, sanocache is regarded as a bidirectional SynchronousQueue?
-
What is the difference between different JDK versions?
-
Sano4 Implementation mechanism?
-
The Slot node is already available. Why is the Slot node added to the arena node array? When do you use arrays?
-
Arenas ensure that different slots in arenas do not conflict, so how is this guaranteed?
-
What is false sharing and how is it represented in SANO11003?
-
Application Example of Saner
-
Java concurrency – ThreadLocal details
-
What is ThreadLocal? What kind of problem is it for?
-
Tell us what you understand about ThreadLocal
-
How does ThreadLocal implement thread isolation?
-
Why does ThreadLocal cause memory leaks? How to solve
-
What are the other scenarios for using ThreadLocal?
Previous hot articles:
- Summary of Java basic knowledge
- Performance Tuning Series topics (JVM, MySQL, Nginx, and Tomcat)
- From being kicked out to 5 offers of 30K+, I have come a long way
- 100 Java project parsing, with source code and learning documentation!
end