SlideShare a Scribd company logo
concurrent package classes
CountDownLatch Example
How to use?
1. new CountDownLatch with count
number
2. Pass CountDownLatch instance to
many threads for doing something
and counting down
3. Pass CountDownLatch instance to
one or many threads to wait for
counting down to zero
4. Thread will keep running after
counting down to zero
CountDownLatch Example
CylicBarrier
● Call await after work finished
● Thread will wait until all
thread finished
CylicBarrier example
Phaser
1. Register for each threads
2. Call arrive if job of current phase
finish
3. Call arriveAndAwaitAdvance if
you need wait for everyone
finished
4. Whenever all registered Phaser
arrived, phase will advance and
onAdvance method will be
called
Phaser example
Exchanger
Only one concept in Exchanger ⇒ exchange.
Used to exchange object between threads.
Exchanger Example
Reference: ExchangerMain.java
Semaphore
Number of permits to be acquired or released.
1. acquire: grab permit(s), wait until all available
2. tryAcquire: grab permit(s) until given timeout
3. release: release permit(s)
4. drainPermits: grab ALL permits
5. availablePermits: get current available permits count
Reference: Semaphore.java
Semaphore Example - TicketPool
Semaphore Example - TicketGrabber
Semaphore Example - TicketSellPoint and Main

More Related Content

DOCX
All functions
PPTX
Programming ii
PPT
Semaphores and Monitors
PPTX
Semophores and it's types
PDF
PyParis2017 / Tutorial transcript - Function-as-a-service : a pythonic perspe...
PPTX
Semaphore
PDF
RBuilder and ByteSurgeon
PPTX
Chap3 clientsrvr
All functions
Programming ii
Semaphores and Monitors
Semophores and it's types
PyParis2017 / Tutorial transcript - Function-as-a-service : a pythonic perspe...
Semaphore
RBuilder and ByteSurgeon
Chap3 clientsrvr

What's hot (7)

PPT
Behavioral Reflection
PPT
Stoop 305-reflective programming5
PPTX
44CON 2014 - Meterpreter Internals, OJ Reeves
PPTX
PDF
Runtime Bytecode Transformation for Smalltalk
PPTX
Scapy TLS: A scriptable TLS 1.3 stack
Behavioral Reflection
Stoop 305-reflective programming5
44CON 2014 - Meterpreter Internals, OJ Reeves
Runtime Bytecode Transformation for Smalltalk
Scapy TLS: A scriptable TLS 1.3 stack
Ad

Similar to Concurrent package classes (20)

PPTX
Thread syncronization
PPT
Csphtp1 14
PPT
Md09 multithreading
PDF
Delphi - Howto Threads
PPT
Multithreading Presentation
PPTX
econtent thread in java.pptx
PPT
Heap & thread dump
PPT
Chap2 2 1
PDF
Java threading
PDF
Sync, async and multithreading
PPTX
Multithreading in java
PPTX
Lecture 23-24.pptx
PPTX
Multithreading in java
PDF
CSE 3146 M1- MULTI THREADING USING JAVA .pdf
PDF
Variables in Pharo
PPTX
Java-7 Concurrency
PPTX
Java Thread
PPTX
java.pptxytbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
PPTX
Multi-Threading in Java power point presenetation
PPTX
Thread syncronization
Csphtp1 14
Md09 multithreading
Delphi - Howto Threads
Multithreading Presentation
econtent thread in java.pptx
Heap & thread dump
Chap2 2 1
Java threading
Sync, async and multithreading
Multithreading in java
Lecture 23-24.pptx
Multithreading in java
CSE 3146 M1- MULTI THREADING USING JAVA .pdf
Variables in Pharo
Java-7 Concurrency
Java Thread
java.pptxytbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
Multi-Threading in Java power point presenetation
Ad

More from Isaac Liao (9)

PDF
Design of everyday things fundamental principles of interaction - V2
PDF
Design of everyday things fundamental principles of interaction
PDF
Java reference objects basic
PDF
Effective java item 80 and 81
PDF
Effective java item 80 prefer executors, tasks, and streams to threads
PDF
Coding practice
PDF
Count downlatch & implementation
PDF
Study effective java item 78 synchronize access to mutable data
PDF
Concurrency
Design of everyday things fundamental principles of interaction - V2
Design of everyday things fundamental principles of interaction
Java reference objects basic
Effective java item 80 and 81
Effective java item 80 prefer executors, tasks, and streams to threads
Coding practice
Count downlatch & implementation
Study effective java item 78 synchronize access to mutable data
Concurrency

Recently uploaded (20)

PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Nekopoi APK 2025 free lastest update
PDF
medical staffing services at VALiNTRY
PPTX
history of c programming in notes for students .pptx
PPTX
Transform Your Business with a Software ERP System
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
ai tools demonstartion for schools and inter college
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Designing Intelligence for the Shop Floor.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Nekopoi APK 2025 free lastest update
medical staffing services at VALiNTRY
history of c programming in notes for students .pptx
Transform Your Business with a Software ERP System
CHAPTER 2 - PM Management and IT Context
VVF-Customer-Presentation2025-Ver1.9.pptx
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
ai tools demonstartion for schools and inter college
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Computer Software and OS of computer science of grade 11.pptx
2025 Textile ERP Trends: SAP, Odoo & Oracle
PTS Company Brochure 2025 (1).pdf.......
Reimagine Home Health with the Power of Agentic AI​
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Digital Systems & Binary Numbers (comprehensive )
Upgrade and Innovation Strategies for SAP ERP Customers
Embracing Complexity in Serverless! GOTO Serverless Bengaluru

Concurrent package classes