Argh. Stupid GMail sent it prematurely.
If, for example, you were trying to allocate an array of arrays concurrently, then I would write (using my namespaces :-) ):
array := Concurrent.Collections.Array new: 1000000000. " We ignore the cost of making this array to begin with :-) "
array withIndexdo: [ :each :i |
��� " each will always be nil. "
��� array at: i put: (Array new: 10).
].
Concurrent.Collections.Array>>withIndexDo: aBlock
���� | nThreads sema |
��� nThreads := 1000. " Pull this from a system setting or something. "
��� sema := Semaphore withSignals: 0-nThreads. " Needs implementing: signal it -1000 times (or -999 or -1001? Unsure) "
��� 1 to: nThreads do: [ :i |
������� [ (nThreads*i) to: (nThreads*i - 1) do: [ :j
����������� aBlock value: (self at: j) value: j ]
�������� sema signal.
�������� ] fork ].
��� sema wait.
��� ^ self.