Ruby - Concurrent Programming
Identify the issue in this Ruby code related to thread safety and suggest a fix:
mutex = Mutex.new
counter = 0
threads = 3.times.map do
Thread.new do
100.times do
counter += 1
end
end
end
threads.each(&:join)
puts counter