13_Review Lecture

Unlock has to be the same condi4on not

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t(), signal(), and signalAll() methods on a condition. 40 Addi4onal Note on Java Monitor •  The book recommends the use of locks. •  This is not a good recommenda4on. Java monitor is more frequently used. •  Monitor is both a lock and a condi4on variable •  Any object in Java is a monitor class Task implements Runnable { sta4c String google_; public void run() { google_ = google_ + “a”; } } class Task implements Runnable { sta4c String google_; public void run() { google_ = google_ + “b”; } } Using locks class Task implements Runnable { sta4c String google_; public void run() { lock.lock(); google_ = google_ + “a”; lock.unlock(); } } class Task implements Runnable { sta4c String google_; public void run() { lock.lock(); google_ = google_ + “b”;...
View Full Document

This document was uploaded on 03/11/2014.

Ask a homework question - tutors are online