Thread: Help!!!!!!!!!!!
View Single Post
Old May 5th, 2008, 8:22 PM   #11
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 532
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: Help!!!!!!!!!!!

Here is the MS-Windows version of that program using VC++ 2008 Express
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>

int myglobal;

 DWORD WINAPI thread_function(LPVOID arg) {
  int i,j;
  for ( i=0; i<20; i++ ) {
    j=myglobal;
    j=j+1;
    printf(".");
    fflush(stdout);
   Sleep(1000);
    myglobal=j;
  }
  return 0;
}

int main(void) {

  int i;
  HANDLE hThread = CreateThread(0, 0, thread_function, 0, 0, 0);  
  if ( hThread == NULL ) {
    printf("error creating thread.");
    return 1;
  }

  for ( i=0; i<20; i++) {
    myglobal=myglobal+1;
    printf("o");
    fflush(stdout);
    Sleep(1000);
  }

  printf("\nmyglobal equals %d\n",myglobal);
  return 0;
}
__________________
I Like Ike. Vote for Dwight Eisenhower this November.
--This message brought to you by the the Procrastinators Club Of America.
Ancient Dragon is offline   Reply With Quote