mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Bugfix in test program!
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4590 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fd379e9937
commit
fc054337ac
2 changed files with 8 additions and 5 deletions
|
@ -1,7 +1,9 @@
|
|||
Wed Jul 14 17:36:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
Wed Jul 14 20:19:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSThread.m: Make sure that a thread retains the target object
|
||||
and argument of the method with which it is detached.
|
||||
* Testing/diningPhilosophers.m: Fixed bug - was passing non NSObject
|
||||
argument.
|
||||
|
||||
Wed Jul 14 16:58:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSThread.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
|
||||
// Conditions
|
||||
#define NO_FOOD 1
|
||||
|
@ -50,7 +51,7 @@ id forks[5];
|
|||
}
|
||||
|
||||
// Instance methods
|
||||
- (void)sitAtChair:(int)position;
|
||||
- (void)sitAtChair:(NSNumber*)position;
|
||||
- (int)chair;
|
||||
|
||||
@end
|
||||
|
@ -58,12 +59,12 @@ id forks[5];
|
|||
@implementation Philosopher
|
||||
|
||||
// Instance methods
|
||||
- (void)sitAtChair:(int)position
|
||||
- (void)sitAtChair:(NSNumber*)position
|
||||
{
|
||||
int i;
|
||||
|
||||
// Sit down
|
||||
chair = position;
|
||||
chair = [position intValue];
|
||||
|
||||
// Its a constant battle to feed yourself
|
||||
while (1)
|
||||
|
@ -131,7 +132,7 @@ int main()
|
|||
// Have them sit at the table
|
||||
for (i = 0;i < 5; ++i)
|
||||
[NSThread detachNewThreadSelector:@selector(sitAtChair:)
|
||||
toTarget:p[i] withObject: (id)i];
|
||||
toTarget:p[i] withObject: [NSNumber numberWithInt: i]];
|
||||
|
||||
// Now let them all eat
|
||||
for (i = 0;i < 5; ++i)
|
||||
|
|
Loading…
Reference in a new issue