blob: 11366211a8e6b58ba57a41ebceb4a39e07afa1df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#!/usr/bin/env ruby
require 'thread'
a = []
threads = []
mutex = Mutex.new
('a'..'r').each { |i|
threads << Thread.new(i) { |c|
mutex.synchronize { a << i }
}
}
threads.each { |t| t.join }
puts a.to_s
|