File tree 1 file changed +35
-6
lines changed
1 file changed +35
-6
lines changed Original file line number Diff line number Diff line change @@ -22,18 +22,47 @@ - (void)viewDidLoad {
22
22
23
23
- (IBAction )redo : (id )sender {
24
24
25
- // [self apply ];
25
+ // [self applytest ];
26
26
27
- // [self iterationsManunal];
27
+ [self semaphore ];
28
+
29
+ }
30
+
31
+ // MARK:<dispatch_semaphore_t---信号量相关>
32
+
33
+ - (void )semaphore {
28
34
29
- // [self nastedApplySC];
35
+ dispatch_group_t group = dispatch_group_create ();
36
+ dispatch_semaphore_t semaphore = dispatch_semaphore_create (10 );
37
+ dispatch_queue_t queue = dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 );
38
+
39
+
40
+ for (int i = 0 ; i < 100 ; i++){
41
+ dispatch_semaphore_wait (semaphore, DISPATCH_TIME_FOREVER);
42
+ dispatch_group_async (group, queue, ^{
43
+ NSLog (@" %i --%@ " ,i,[NSThread currentThread ]);
44
+ sleep (2 );
45
+ dispatch_semaphore_signal (semaphore);
46
+ });
47
+ }
48
+ dispatch_group_wait (group, DISPATCH_TIME_FOREVER);
49
+ }
50
+
51
+ // MARK:<dispatch_apply---apply相关>
30
52
31
- // [self nastedApplyCC];
53
+ - ( void ) applytest {
32
54
33
- // [self nastedApplySS ];
55
+ // [self apply ];
34
56
35
- [self nastedApplyCS ];
57
+ // [self iterationsManunal];
58
+
59
+ // [self nastedApplySC];
36
60
61
+ // [self nastedApplyCC];
62
+
63
+ // [self nastedApplySS];
64
+
65
+ [self nastedApplyCS ];
37
66
}
38
67
39
68
/* !
You can’t perform that action at this time.
0 commit comments