Hi All,
I'm trying to learn concurrent programming and am a novice to C/C++ - Could anyone help please?
I hope to create a thread using the 'CreateThread' API call and print just 2 simple messages. Unfortunately, the only message that appears is 'Hello from the main function' - nothing from 'MyThread1'. Could anyone tell me what is wrong please?
Also, I need to use semphores later on in my course. How are these declared?
#include <windows.h>
#include <stdio.h>
//prototypes
long WINAPI MyThread1(long lParam);
int main(void)
{
HANDLE hThread;
DWORD dwThreadID;
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MyThread1, NULL, 0, &dwThreadId);
printf( "Hello from the main function" );
return 0;
}
long WINAPI MyThread1(long lParam)
{
printf("Thread 1 active"
return 0L;
}
Thanks for your time and help,
James.
I'm trying to learn concurrent programming and am a novice to C/C++ - Could anyone help please?
I hope to create a thread using the 'CreateThread' API call and print just 2 simple messages. Unfortunately, the only message that appears is 'Hello from the main function' - nothing from 'MyThread1'. Could anyone tell me what is wrong please?
Also, I need to use semphores later on in my course. How are these declared?
#include <windows.h>
#include <stdio.h>
//prototypes
long WINAPI MyThread1(long lParam);
int main(void)
{
HANDLE hThread;
DWORD dwThreadID;
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MyThread1, NULL, 0, &dwThreadId);
printf( "Hello from the main function" );
return 0;
}
long WINAPI MyThread1(long lParam)
{
printf("Thread 1 active"
return 0L;
}
Thanks for your time and help,
James.