Skip to content

Instantly share code, notes, and snippets.

@anhnguyen1618
Last active December 8, 2019 19:53
Show Gist options
  • Save anhnguyen1618/69a744e1871a81c79792c56569ede147 to your computer and use it in GitHub Desktop.
Save anhnguyen1618/69a744e1871a81c79792c56569ede147 to your computer and use it in GitHub Desktop.
class Shop {
barber() {
while(freeSeat == N) wait()
freeSeat += 1
busy = true
}
close() {
busy = false
notifyAll()
}
guest() {
if (freeSeat == 0) {
return false;
}
freeSeat -= 1
while(busy == true) {
wait()
}
notifyAll()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment