Path: utzoo!attcan!uunet!husc6!rutgers!psuvax1!psuvm!trearn!turgut From: TURGUT@TREARN.BITNET (Turgut Kalfaoglu) Newsgroups: comp.os.os2.programmer Subject: Horses! Message-ID: <90270.152726TURGUT@TREARN.BITNET> Date: 28 Sep 90 03:56:40 GMT Organization: Ege University - Computing Center Lines: 32 I was trying to get Peter Norton's HORSES.C program to work. This program creates 5 threads, each of which are responsible to draw a simple horse picture, and run the horses accross the screen, checking when column 75 is reached, and then declaring the winner. It's a very simple program. The main program simply passes these 'horses' a number from 1 to 5 so that the horses can determine at which line to draw their pictures, and at the end, which one is the winner. I had to make some changes to the code since Norton uses DosBeginThread, with manual creation of a stack with malloc(). So, that all vanished, and replaced by a _beginthread. Here is the curiosity: if I put a DosSleep(0L) in the main()'s loop where the beginthread is called five times to create the five horses, everything is fine. If I remove that, five horses are created, but they each receive the same index number (5), and they move together too! (so only one horse appears on display). It roughly looks like this: for (j=0;j<5;j++) { if (_beginthread(horse,NULL,4096,&j) == 0) { printf("Error"); exit(1); } DosSleep(0L); } I remove the DosSleep and it no longer works! Any ideas? Is it a bug in OS/2 1.1 that got corrected with 1.2 ? Also I noticed that if the main() ends, even with DosExit(0,0), all threads are killed, which is contrary to Peter Norton's book.. Regards, -turgut