mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-04 13:50:55 +00:00
defines for earlier version of Mac OS X back to 10.0. * Source/synchronization.m: Correct a problem found during testing. * Testing/synctest/main.m: Updated test. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27136 72102866-910b-0410-8b05-ffd578937521
36 lines
962 B
Objective-C
36 lines
962 B
Objective-C
#import <Foundation/Foundation.h>
|
|
|
|
static NSArray *array;
|
|
|
|
@interface SyncTest : NSObject
|
|
- (void) sayHello;
|
|
@end
|
|
|
|
@implementation SyncTest
|
|
- (void) sayHello
|
|
{
|
|
NSLog(@"Before the sync block %s\n",[[[NSThread currentThread] description] cString]);
|
|
@synchronized(array) {
|
|
NSLog(@"In the sync block %s:%d\n",[[[NSThread currentThread] description] cString], [NSThread isMainThread]);
|
|
NSLog(@"Waiting five seconds...\n");
|
|
[NSThread sleepForTimeInterval: 5.0];
|
|
NSLog(@"Done waiting\n");
|
|
}
|
|
NSLog(@"After the sync block %s\n",[[[NSThread currentThread] description] cString]);
|
|
}
|
|
@end
|
|
|
|
int main (int argc, const char * argv[])
|
|
{
|
|
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
|
SyncTest *st = [[SyncTest alloc] init];
|
|
array = [NSArray arrayWithObjects: @"Hello World",nil];
|
|
|
|
[NSThread detachNewThreadSelector: @selector(sayHello)
|
|
toTarget: st
|
|
withObject: nil];
|
|
[st sayHello];
|
|
|
|
[pool drain];
|
|
return 0;
|
|
}
|