[MacRuby-devel] Thread safety in apply example?
Charles Oliver Nutter
headius at headius.com
Fri Jan 21 21:57:25 PST 2011
I'm curious about this example in Queue#apply's rdoc:
* gcdq = Dispatch::Queue.new('doc')
* @result = []
* gcdq.apply(5) {|i| @result[i] = i*i }
* p @result #=> [0, 1, 4, 9, 16, 25]
apply is said to issue the jobs in parallel, so this would be making
concurrent updates to the @result array. Are simple arrays in MacRuby
thread-safe?
- Charlie
More information about the MacRuby-devel
mailing list