[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Thread question
From: |
Richard Frith-Macdonald |
Subject: |
Re: Thread question |
Date: |
Tue, 1 Mar 2011 18:31:19 +0000 |
On 1 Mar 2011, at 17:55, Banlu Kemiyatorn wrote:
> Hi,
> I need help on NSThread, Here,s the code
>
> @implementation MyObj
> - (void) launch
> {
> // id p = [NSAutoreleasePool new];
> NSLog(@"x");
> //[p release];
> }
> @end
>
> int main (int argc, const char * argv[]) {
> id p = [NSAutoreleasePool new];
>
> id obj = [MyObj new];
> [NSThread detachNewThreadSelector:@selector(launch)
> toTarget:obj withObject:nil];
> [NSThread detachNewThreadSelector:@selector(launch)
> toTarget:obj withObject:nil];
> /* some sleep */
>
>
> I got
> Uncaught exception NSLockException, reason: failed to unlock mutex
> But if I NSLock NSLog, it will log 2 "x"
> Does this mean NSLog isn't thread-safe? or what do I miss?
NSLog should be thread-safe.
The code you provide is incomplete and certainly won't even compile, so we
can't really tell what your problem might be.
Please write a complete testcase demonstrating what your problem is...
You can get the latest gnustep-make from svn trunk and try 'gnustep-tests
--help' to get started ...
There are example tests in $GNUSTEP_MAKEFILES/TestFramework
- Thread question, Banlu Kemiyatorn, 2011/03/01
- Re: Thread question,
Richard Frith-Macdonald <=
- Re: Thread question, Banlu Kemiyatorn, 2011/03/01
- Re: Thread question, Richard Frith-Macdonald, 2011/03/02
- Re: Thread question, Richard Frith-Macdonald, 2011/03/02
- Re: Thread question, Banlu Kemiyatorn, 2011/03/04
- Re: Thread question, Richard Frith-Macdonald, 2011/03/04
- Re: Thread question, Banlu Kemiyatorn, 2011/03/04
- Re: Thread question, Richard Frith-Macdonald, 2011/03/05
- Re: Thread question, Philippe Roussel, 2011/03/07
- Re: Thread question, Richard Frith-Macdonald, 2011/03/07
- Re: Thread question, Philippe Roussel, 2011/03/07