Skip to content

Commit

Permalink
Two small fixes
Browse files Browse the repository at this point in the history
Missing #import added to one of examples for those who decide run example in Xcode.
Wrong var declaration fixed in another snippet.
  • Loading branch information
valeriyvan committed Nov 25, 2014
1 parent ba330e1 commit 933e30c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions 2013-07-07-concurrency-apis-and-pitfalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ The important thing to keep in mind is that you have no control over where and w

Leaving this complexity aside for a moment, you can either use the [POSIX thread](http://en.wikipedia.org/wiki/POSIX_Threads) API, or the Objective-C wrapper around this API, `NSThread`, to create your own threads. Here's a small sample that finds the minimum and maximum in a set of 1 million numbers using `pthread`. It spawns off 4 threads that run in parallel. It should be obvious from this example why you wouldn't want to use pthreads directly.


#import <pthread.h>

struct threadInfo {
uint32_t * inputValues;
size_t count;
Expand Down Expand Up @@ -139,7 +140,7 @@ Leaving this complexity aside for a moment, you can either use the [POSIX thread

To start new threads, we need to create new thread objects and call their `start` methods:

NSSet *threads = [NSMutableSet set];
NSMutableSet *threads = [NSMutableSet set];
NSUInteger numberCount = self.numbers.count;
NSUInteger threadCount = 4;
for (NSUInteger i = 0; i < threadCount; i++) {
Expand Down

0 comments on commit 933e30c

Please sign in to comment.