Java concurrent programming in the fifth chapter of synchronization container class reading notes

Source: Internet
Author: User


First, the Synchronization container class1. Issues with the synchronization container classThread container classes are thread-safe. However, it is necessary to protect the safety of an additional lock when it is carried out in accordance with the operation.
Common compliance actions include:
. Iterations. Jumps (finds the next element of the current element in the specified order). Conditional operations
Iterative issues to view previous articles, "Java concurrentmodificationexception exception analysis and Resolution"

Second, concurrent containers
Collection type Non-thread safe Thread Safety
List ArrayList Copyonwritearraylist
Set SortedSet Concurrentskiplistset
Map HashMap, SortedMap Concurrenthashmap, Concurrentskiplistmap,


Concurrenthashmapcopyonwritearraylist
Third, block queue-producer consumer mode queue-Blockingqueue

Iv. blockage method and interruption method the following excerpt from "Win Shaojin-Java Concurrent Programming Tutorial-"
The first way thread thread = new Thread ("Interrupt test") {public     void run () {for          (;;) {               doxxx ();               if (thread.interrupted ()) {Break                    ;}}}     ; Thread.Start ();///Another way thread thread = new Thread ("Interrupt test") {public     void run () {for          (;;) {               try {                    doxxx ();               } catch (Interruptedexception e) {break                    ;               } catch (Exception e) {                    // Handle Exception               }          }     }};thread.start ();//Third Way public void Foo () throws interruptedexception {     if (Thread.interrupted ()) {          throw new interruptedexception ();     }}



The program should respond appropriately to thread interrupts.


Five, the Synchronization tool Class 1. Latching CountDownLatch2. FutureTask3. Signal Volume 4. Fence (Barrier)
Vi. building an efficient and scalable results cache

Java concurrent programming in the fifth chapter of synchronization container class reading notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.