NSThread(Waiting)


Abstract

Adds the ability to wait for a thread to wait until a certain number of threads exist.

Discussion

When waiting for the number of running threads to drop to a certain value, this is like joining threads without specifying which threads are joined.

Methods

+detachedThreads
Returns the number of running threads.
+sleepUntilThreadsNumber:
Causes thread to block until numberOfThreads remain.

detachedThreads


Returns the number of running threads.

+ (int)detachedThreads;
Discussion

Returns the number of threads detached by detachNewCountedThreadSelector:toTarget:withObject:.
N.B.: threads not detached explicitly using detachNewCountedThreadSelector:toTarget:withObject: will not be counted as running.


sleepUntilThreadsNumber:


Causes thread to block until numberOfThreads remain.

+ (void)sleepUntilThreadsNumber:(int) numberOfThreads;
Discussion

Block until the number of threads detached by detachNewCountedThreadSelector:toTarget:withObject: reaches numberOfThreads. If multiple threads finish or start before the thread calling this method is signalled such that the number of counted threads is not equal to numberOfThreads, this thread may continue to block.
N.B.: threads not detached explicitly using detachNewCountedThreadSelector:toTarget:withObject: will not be counted as running.

(Last Updated March 11, 2007)