Skip to content

Commit 6df2828

Browse files
committed
Merge pull request #1 from saks/patch-1
wait for threads to finish in a ruby way
2 parents 9713861 + fcd6305 commit 6df2828

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

concurrency/ruby/hello1.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
count = 0
2+
threads = []
23

34
10.times do |i|
4-
Thread.new do
5+
threads << Thread.new do
56
greeting_message = "Hello"
67

78
# This is weird in Ruby but it's closer to the println! macro
@@ -13,6 +14,4 @@
1314
end
1415

1516
# wait for all thread finishes
16-
while count < 10 do
17-
# do nothing
18-
end
17+
threads.each &:joni

0 commit comments

Comments
 (0)