Multi-threaded Chapters

join method thread is a thread running of the process must wait until the complete thread running join method to make the current thread continues to run. The principle is checking join the thread is alive, survival has been circulating to wait until the thread over, and it continues to run down.
volitile is to make communication between threads to solve the reordering of the compiler, the program is run in accordance with the normal flow of execution,

jstat virtual machine monitor command various operating states, including garbage collection, memory, a class loader
jstat -gc pid each partition can monitor information memory heap

jstack: stack trace tools
custom class loader needs to be rewritten findClass ()

ConcurrentHashMap () operation is to be put to find hash segment, then the segment lock, the safety and efficiency are possible. Concurrent use, do not use HashMap
ConcurrentLinkedQueue thread-safe queue, its performance is better than blockingqueue

java a clog in the queue
arrayBlockingQueue: an array structure of unbounded blocking queue
linkedBlockingQueue: linked list structure consisting of a bounded queue, linkedTransferQueue: a linked list of structures of unbounded blocking queue, linkedBlockingDeque: list consisting of two-way blocking queue

Fork / join the frame (multithreaded):
object is to split a large task, subtask each run separately, the task of the method to obtain the results join call task, classes need to inherit recursiveTask, override Compute () method
between threads exchange exchanger can be used to verify whether the data are consistent with the two threads of the same data processing operations.

Control the number of concurrent threads semaphore: for example, only 100 vehicles passing on a highway, other cars can only wait at the junction.

CyclicBarrier and CountDownLatch difference:

CountDownLatch counter can only be used once, and the counter can CyclicBarrier REST () method of resetting, so CyclicBarrier can handle more complex business scenario.

Guess you like

Origin www.cnblogs.com/ljy-skill/p/11111379.html