summaryrefslogtreecommitdiff
path: root/sample/philos.rb
diff options
context:
space:
mode:
Diffstat (limited to 'sample/philos.rb')
-rw-r--r--sample/philos.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/sample/philos.rb b/sample/philos.rb
index 119e7c36b9..c38aa4a1cc 100644
--- a/sample/philos.rb
+++ b/sample/philos.rb
@@ -1,14 +1,13 @@
#
# The Dining Philosophers - thread example
#
-require "thread"
srand
#srand
N=9 # number of philosophers
$forks = []
for i in 0..N-1
- $forks[i] = Mutex.new
+ $forks[i] = Thread::Mutex.new
end
$state = "-o"*N
@@ -25,7 +24,7 @@ def eat(n)
end
def philosopher(n)
- while TRUE
+ while true
think n
$forks[n].lock
if not $forks[(n+1)%N].try_lock