Skip to content

Instantly share code, notes, and snippets.

@seadowg
Created May 20, 2012 13:32
Show Gist options
  • Save seadowg/2758143 to your computer and use it in GitHub Desktop.
Save seadowg/2758143 to your computer and use it in GitHub Desktop.
Semaphore implementation with Scala's synchronized
class Semaphore(private var count : Int) {
def p() {
synchronized {
while (count < 1) {}
count = count - 1
}
}
def v() {
synchronized {
count = count + 1
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment