Skip to content

Instantly share code, notes, and snippets.

@benash
Created June 3, 2010 01:39
Show Gist options
  • Save benash/423302 to your computer and use it in GitHub Desktop.
Save benash/423302 to your computer and use it in GitHub Desktop.
require 'thread'
semaphore = Mutex.new
a = Thread.new {
semaphore.synchronize {
# access shared resource
}
}
b = Thread.new {
semaphore.synchronize {
# access shared resource
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment