C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[41179] [질문]스레드를 쓰고 싶은데 사용법이 이해가 않가요~
RedEye [interrupter] 842 읽음    2005-07-23 17:17
아래 문장은 도움말에 나오는 사항인데요~.

제 컴푸터 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;
}

+ -

관련 글 리스트
41179 [질문]스레드를 쓰고 싶은데 사용법이 이해가 않가요~ RedEye 842 2005/07/23
41182     Re:[질문]스레드를 쓰고 싶은데 사용법이 이해가 않가요~ smleelms 1123 2005/07/23
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.