信号量
2018-08-22 本文已影响6人
絮语时光杨
//声明信号量
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
//信号量加1
dispatch_semaphore_signal(semaphore);
//信号量减一
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
//声明信号量
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
//信号量加1
dispatch_semaphore_signal(semaphore);
//信号量减一
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);