j'ai un problème ...NSThread dans MainThread
Je en ai besoin:
Créer un nouveau fil, et une pause, il (en attente d'une notification de la MainThread). Dans MainThread, appuyez sur un déclencheur pour reprendre ce fil d'arrière-plan.
En MainThread:
[NSThread detachNewThreadSelector:@selector(startTheBackgroundJob:) toTarget:self withObject:nil];
en fil de fond:
- (void) startTheBackgroundJob {
@autoreleasepool {
NSLog(@"+ Thread %@ started and waiting.", self.identifier);
// Pause Here
NSLog(@"- Thread %@ unlocked", self.identifier);
[Scheduler doneTransaction: self];
}
}
MainThread:
- (void) unlock {
// resume a background thread
}
J'ai essayé NSLock, NSConditionLock et Sémaphore GCD ....
Comment avez-vous essayé d'utiliser des verrous et des sémaphores, montrez ce code. – Wain
@Wain https://gist.github.com/iagocc/b2086b0abc329d46abca –
Je suppose que l'ARC libère prématurément le sémaphore. Essayez de faire l'attribut __strong. – Wain