Put the objects into a queue first and then let each thread dequeue an item to use. If you were using .NET 4.0 or later, the obvious choice would be the ConcurrentQueue(Of T), which is inherently thread-safe. As you're using .NET 3.5 or earlier, you should use a Queue(Of T) and synchronise the dequeuing yourself, e.g.Code:Private ReadOnly items As New Queue(Of Object) Private ReadOnly syncRoot As New Object Private Function GetNextItem() As Object SyncLock syncRoot Return items.Dequeue() End SyncLock End Function




Reply With Quote