Supplement: some common methods and summary of the first stage

catalogue pork and Interrupted() methods Exercise 2 Daemon thread Thread status: Example: washing a teapot (multithreading problem) Summary: pork and Interrupted() methods pork: terminate the thread and the following will no longer run. In fact, it is based on the thread state. If it is true, it can be executed down Thread.interru ...

Posted by macinjosh on Fri, 01 Apr 2022 14:26:38 +0300

Concurrent HashMap for reading through the collection source code

Pre class comments This class contains all the methods in HashTable.This hash table is thread safe and does not require or even cannot lock the entire table.In the concurrent scenario, the results obtained by calling such methods as size, isEmpty and containsValue can only reflect the state in a short period of time. Therefore, do not take ...

Posted by moise on Fri, 01 Apr 2022 00:47:05 +0300

Take a few minutes to understand how to configure the number of core threads in the thread pool

catalogue 1, Background 2, What are the number of CPU cores and logical processors 3, CPU intensive and IO intensive 4, Determination of the number of core threads in the thread pool 5, Taskpoolexecutor implementation code 1, Background In order to realize asynchrony, it is necessary to open a new thread to handle the task and call the ...

Posted by hstraf on Thu, 31 Mar 2022 16:39:31 +0300

How to use CountDownLatch, CyclicBarrier and Semaphore and the differences between them

Some common synchronization tool classes are included under JUC. Today, let's introduce in detail the usage methods of CountDownLatch, CyclicBarrier and Semaphore and the differences between them. 1, CountDownLatch Let's take a look at the official introduction of the source code of CountDownLatch. picture This means that it is a synchronizatio ...

Posted by chu70077 on Wed, 30 Mar 2022 21:20:48 +0300