grosser/parallel — pull request #27 by ryanlecompte (2012-01-26 07:36:46+00:00)
Title: Fix race conditions for shared arrays among multiple threads

This pull request addresses issue #26: https://github.com/grosser/parallel/issues/26

The basic idea here is to not treat Ruby's Array class as a thread-safe data structure. Multiple threads try to concurrently write their results into shared arrays, which can introduce race conditions since Array is not thread-safe. The solution is to wrap updates to these arrays in a Thread.exclusive block to ensure that the array remains in a consistent state.