Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 871 Bytes

README.md

File metadata and controls

34 lines (26 loc) · 871 Bytes

#ThreadPool 1.0

Kelp http://kelp.phate.org/
MIT License

Thread Pool is a thread queue.
You could push threads to ThreadPool, and then it will process the thread.

ThreadPool *pool = [ThreadPool new];

NSThread *thread = [[NSThread alloc] initWithTarget:self
                                           selector:@selector(threadExecuteCode)
                                             object:nil];
thread.name = @"Thread A";
[pool pushThread:thread];

thread = [[NSThread alloc] initWithTarget:self
                                 selector:@selector(threadExecuteCode)
                                   object:nil];
thread.name = @"Thread B";
[pool pushThread:thread];
- (void)threadExecuteCode
{
    for (int index = 0; index < 10; index++) {
        NSLog(@"%@: %i", [NSThread currentThread].name, index);
    }
}