Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC364 Lecture 14

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for Javier Gonzalez-Sanchez Javier Gonzalez-Sanchez PRO
February 26, 2026
90

CSC364 Lecture 14

Introduction to Networked, Distributed, and Parallel Computing
Patterns II
(202602)

Avatar for Javier Gonzalez-Sanchez

Javier Gonzalez-Sanchez PRO

February 26, 2026
Tweet

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 364 Introduction to Networked, Distributed, and Parallel Computing Lecture 14. Concurrency Design Patterns II 1
  2. 3 De f inition • An Immut a ble Object

    c a nnot be modi f ied a fter cre a tion. • Once constructed, its st a te never ch a nges. Wh a t does this p a ttern gu a r a ntee? • Thre a d s a fety by design • No synchroniz a tion required • No r a ce conditions When to Use Immut a ble Objects? • D a t a is sh a red a cross thre a ds • St a te does not need to ch a nge • Simplicity a nd s a fety a re priorities
  3. 5 Code • final on a class prevents extension. •

    final on fields prevents mutation. • Immutability requires both — plus no setters.
  4. 7 De f inition • A thre a d w

    a its (is suspended) until a gu a rd condition becomes true. • Another thre a d l a ter ch a nges the st a te a nd sign a ls the w a iting thre a d to resume. Us a ge: • A Client thre a d w a nts d a t a . • A Worker thre a d produces the d a t a l a ter. • The client w a its s a fely until the d a t a is a v a il a ble.
  5. 13 De f inition • Work f lows through st

    a ges (thre a ds), typic a lly connected by blocking queues. • E a ch st a ge runs concurrently.
  6. 14 Class Condition • A Condition object represents a st

    a te predic a te th a t thre a ds c a n w a it for while holding a lock. • E a ch Condition is tied to one speci f ic lock When a thre a d c a lls a w a it(): • It rele a ses the lock • It goes to sleep When sign a led: • It re- a cquires the lock • Execution resumes a fter a w a it()
  7. CSC 364 Introduction to Introduction to Networked, Distributed, and Parallel

    Computing Javier Gonzalez-Sanchez, Ph.D. [email protected] Winter 2026 Copyright. These slides can only be used as study material for the class CSC 364 at Cal Poly. They cannot be distributed or used for another purpose. 25