@@ -2274,13 +2274,23 @@ puts "==== I am the main thread."
22742274# thread.join # Try to uncomment these two lines to see the differences.
22752275# puts "==== after thread.join"
22762276```
2277- You will find that if there is no` thread.join ` , you can only see` ==== I am the main thread. ` in console.
2277+ You will find that if there is no` thread.join ` , you can see
2278+ ``` log
2279+ ==== I am the main thread.
2280+ ==== after thread.join
2281+ ~~~~ 0
2282+ ~~~~ 1
2283+ ~~~~ 2
2284+ ```
2285+ in console.
22782286
22792287After you added` thread.join ` , you can see:
2280- ``` ruby
2288+ ``` log
2289+ ==== I am the main thread.
2290+ ~~~~ 0
22812291~~~~ 1
22822292~~~~ 2
2283- ~~~~ 3
2293+ ==== after thread.join
22842294````
22852295in console.
22862296
@@ -2289,26 +2299,36 @@ Try to run `test_thread_join2.rb`.
22892299```ruby
22902300# ./test_thread_join2.rb
22912301arr = [
2292- Thread.new { sleep 1 },
22932302 Thread.new do
2294- sleep 5
2303+ puts 'I am arr[0]'
2304+ sleep 1
2305+ puts 'After arr[0]'
2306+ end,
2307+ Thread.new do
22952308 puts 'I am arr[1]'
2309+ sleep 5
2310+ puts 'After arr[1]'
22962311 end,
2297- Thread.new { sleep 8}
2312+ Thread.new do
2313+ puts 'I am arr[2]'
2314+ sleep 8
2315+ puts 'After arr[2]'
2316+ end
22982317]
22992318
2300- puts Thread.list.size # returns 4 (including the main thread)
2319+ puts" Thread.list.size: #{Thread.list.size}" # returns 4 (including the main thread)
23012320
23022321sleep 2
23032322
23042323arr.each { |thread| puts "~~~~~ #{thread}" }
23052324
2306- puts Thread.list.size # returns 3 (because arr[0] is dead)
2325+ puts" Thread.list.size: #{Thread.list.size}" # returns 3 (because arr[0] is dead)
23072326
2308- # arr[1].join # uncomment to see differences
2327+ arr[1].join # uncomment to see differences
23092328
23102329arr.each { |thread| puts "~~~~~ #{thread}" }
23112330
2331+ sleep 7
23122332puts "Exit main thread"
23132333```
23142334