URL loading system not threadsafe?
URL loading system not threadsafe?
- Subject: URL loading system not threadsafe?
- From: Henk Kampman <email@hidden>
- Date: Fri, 18 Nov 2005 14:33:31 +0100
The following code always crashes in NSURLCache (see partial
crashlogs) after running for a few minutes.
It looks as if the default NSURLCache mechanism is broken or not
threadsave, is this correct or am I doing something wrong?
Henk
BTW I'm using a G5 DP2.0 running OSX 10.4.3
#import "MainController.h"
@implementation MainController
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
// spawn 8 threads
[NSThread detachNewThreadSelector:@selector(testThread:)
toTarget:self withObject:nil];
[NSThread detachNewThreadSelector:@selector(testThread:)
toTarget:self withObject:nil];
[NSThread detachNewThreadSelector:@selector(testThread:)
toTarget:self withObject:nil];
[NSThread detachNewThreadSelector:@selector(testThread:)
toTarget:self withObject:nil];
[NSThread detachNewThreadSelector:@selector(testThread:)
toTarget:self withObject:nil];
[NSThread detachNewThreadSelector:@selector(testThread:)
toTarget:self withObject:nil];
[NSThread detachNewThreadSelector:@selector(testThread:)
toTarget:self withObject:nil];
[NSThread detachNewThreadSelector:@selector(testThread:)
toTarget:self withObject:nil];
}
- (void)testThread:(id)anObject
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSURL* url = [NSURL URLWithString: @"http://www.apple.com/"];
while(1)
{
NSAutoreleasePool *innerPool = [[NSAutoreleasePool alloc] init];
NS_DURING
NSData* receivedData = [NSData dataWithContentsOfURL:url];
if(receivedData == NULL)
{
NSLog(@"timeout");
}
NS_HANDLER
NSLog(@"exception");
NS_ENDHANDLER
[innerPool release];
}
[pool release];
}
@end
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden