libs-base/Testing/synctest/main.m
rfm 219c8760e9 avoid warnings about missing autorelease pool
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27256 72102866-910b-0410-8b05-ffd578937521
2008-12-08 08:43:07 +00:00

38 lines
1 KiB
Objective-C

#import <Foundation/Foundation.h>
static NSArray *array;
@interface SyncTest : NSObject
- (void) sayHello;
@end
@implementation SyncTest
- (void) sayHello
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
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]);
[pool release];
}
@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;
}