-
-
Save Morse-Code/796eb9a437ae4474d88a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dispatch_group_t group = dispatch_group_create(); | |
dispatch_semaphore_t semaphore = dispatch_semaphore_create(10); | |
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | |
for (int i = 0; i < 100; i++) | |
{ | |
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); | |
dispatch_group_async(group, queue, ^{ | |
NSLog(@"%i",i); | |
sleep(2); | |
dispatch_semaphore_signal(semaphore); | |
}); | |
} | |
dispatch_group_wait(group, DISPATCH_TIME_FOREVER); | |
dispatch_release(group); | |
dispatch_release(semaphore); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment