====== Week 8 ====== ~~NOTOC~~ ===== Monitors in Java ===== * Java case study (starter code for Assign 4) * this version deadlocks! * you will use two different approaches to fix: * synchronized methods * synchronized code blocks \\ \\ * Obscure Java * shortest compilable Java program? * does it run? * what's it good for? * inner classes * what are they? * what are they good for? * what do they look like when compiled? * what does any of this have to do with the assignment? \\ \\ ===== Assignment: Dining Java Philosophers ===== * Assign 4 * {{ diningjavaphils.pdf |PDF}} * due: Tue, Mar 31, 11:59pm \\ \\ ===== Channels ===== * Communicating Sequential Processes (CSP) and Golang (Go)! * RIP: C.A.R. 'Tony' Hoare (March 5, 2026; 92 years old) * [[https://en.wikipedia.org/wiki/Tony_Hoare|Wikipedia]] * [[https://www.bcs.org/articles-opinion-and-research/celebrating-the-life-of-car-tony-hoare/|BCS Article: Celebrating the Life of C.A.R. 'Tony' Hoare]] * Hoare's [[https://dl.acm.org/doi/pdf/10.1145/359576.359585|1978 CSP paper]] * Hoare's [[https://antares.sip.ucm.es/~luis/doctorado06-07/cspbook.pdf|1985 CSP textbook]] /***** * Go implementation of examples from paper: https://godoc.org/github.com/thomas11/csp ******/ * Rob Pike's Google I/O 2012 - Go Concurrency Patterns: https://youtu.be/f6kdp27TYZs * Peter Welch's slides introducing CSP and occam-pi (but we will use Go this semester!) * [[courses:cs377-202651:welch-lectures:top|Occam-pi Lecture Notes]] * today: * **//Objects Considered Harmful//** (slide 27 of motivation.pdf slides) * even though we won't be programming in occam-pi, I want to give you a flavor of it * because: * ultimate lightweight processes! * composition! * Legoland: slide 83-end of basics.pdf \\ \\ /************ * Demo and codewalk of csp-dining-philosophers.go * Go language features highlighted: * channels * select * Design basis for solution in Go: go routines (processes) * room (communicates with philosophers over channels) * for philosophers to enter/leave -- at most 4 at a time to prevent deadlocking, 5th philosopher blocks * forks (communicate with philosophers over channels) * philosophers (communicate with forks over channels) *************/