|
아래 문장은 도움말에 나오는 사항인데요~.
제 컴푸터 OS는 2000쓰고 있고여,
_beginthread로 시작해서 _end thread로 끝낼려면 어떻게 해서 사용해야되는지 이해 않가요~ ㅜㅜ
Prototype
unsigned long _beginthread(void (_USERENTRY *__start)(void *), unsigned __stksize, void *__arg);
void _endthread(void);
그리고 아직 초보라 원형만 보고 프로그램하기가 힘드네요~ 보통 원형을 보고 어떻게 쉽게 이해할수있나요?
스레드의 시작과 끝을 적용해서 여러게의 펑션을 구동시켜 보고 싶습니다.
도와주세요~
/* Use the -tWM (32-bit multi-threaded target) command-line switch for this example */
#include <stdio.h>
#include <errno.h>
#include <stddef.h> /* _threadid variable */
#include <process.h> /* _beginthread, _endthread */
#include <time.h> /* time, _ctime */
void thread_code(void *threadno)
{
time_t t;
time(&t);
printf("Executing thread number %d, ID = %d, time = %s\n",
(int)threadno, _threadid, ctime(&t));
}
void start_thread(int i)
{
int thread_id;
#if defined(__WIN32__)
if ((thread_id = _beginthread(thread_code,4096,(void *)i)) == (unsigned long)-1)
#else
if ((thread_id = _beginthread(thread_code,4096,(void *)i)) == -1)
#endif
{
printf("Unable to create thread %d, errno = %d\n",i,errno);
return;
}
printf("Created thread %d, ID = %ld\n",i,thread_id);
}
int main(void)
{
int i;
for (i = 1; i < 20; i++)
start_thread(i);
printf("Hit ENTER to exit main thread.\n");
getchar();
return 0;
}
|