libs-base/Tests/base/NSLock/Helpers/doubleNSLock.m
rfm f406e096dc Make locking checks more robust
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32314 72102866-910b-0410-8b05-ffd578937521
2011-02-23 08:08:22 +00:00

41 lines
939 B
Objective-C

#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSLock.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSThread.h>
#import <Foundation/NSUserDefaults.h>
@interface MyClass : NSObject
+ (void) run;
@end
@implementation MyClass
+ (void) run
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSLock *lock = [NSLock new];
[lock lock];
[lock lock];
[arp release];
}
@end
int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
/* We need the user defaults system set up to allow NSLog to query it
* when logging the deadlock message, but if the main thread is
* sleeping then it can't get set up. So we set it up before we
* start the test.
*/
[NSUserDefaults standardUserDefaults];
[NSThread detachNewThreadSelector: @selector(run)
toTarget: [MyClass class]
withObject: nil];
[NSThread sleepForTimeInterval: 1.0];
NSLog(@"Done.");
[arp release];
return 0;
}