//
//  NSThreadExtensionDemo.h
//  NSThreadExtension
//
//  Created by Jonathan Lung on 10/03/07.
//  Copyright 2007 Jonathan Lung. All rights reserved.
//  http://www.cs.toronto.edu/~lungj

#import <Foundation/Foundation.h>
#import "NSThreadWaiter.h"
#import "RandomThread.h"
int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

	struct timeval tv;
	gettimeofday(&tv, NULL);
    int seed=tv.tv_usec;
    srand(seed);

	int threads = 0;
	for (threads = 0; threads < 5; threads++) {
		[NSThread detachNewCountedThreadSelector:@selector(run:) toTarget:[[[RandomThread alloc] init] autorelease] withObject:[NSNumber numberWithInt:threads]];
	}

	[NSThread sleepUntilThreadsNumber:0];
	NSLog(@"All detached threads finished.");
	
    [pool release];
    return 0;
}
