• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            穩(wěn)定盈利的期貨交易方法-量化趨勢交易

            alantop -專業(yè)量化投資者

            愛好:量化投資,逆向工程,滲透
            隨筆 - 595, 文章 - 0, 評論 - 921, 引用 - 0
            數(shù)據(jù)加載中……

            CreateThread示例。

            The CreateThread function creates a new thread for a process. The creating thread must specify the starting address of the code that the new thread is to execute. Typically, the starting address is the name of a function defined in the program code (for more information, see ThreadProc). This function takes a single parameter and returns a DWORD value. A process can have multiple threads simultaneously executing the same function.

            CreateThread 函數(shù)從一個進程里面創(chuàng)建一個線程。這個開始的線程必須指定開始執(zhí)行代碼的地址,新線程執(zhí)行。有代表性的,開始地址就是一個函數(shù)名。這個函數(shù)有一個參數(shù),并且返回一個 DWORD 值。一個進程里面同時有多個線程在執(zhí)行。

            ?

            The following is a simple example that demonstrates how to create a new thread that executes the locally defined function, ThreadProc. The creating thread uses a dynamically allocated buffer to pass unique information to each instance of the thread function. It is the responsibility of the thread function to free the memory.

            下面這個例子演示如何創(chuàng)建一個新線程,執(zhí)行本地定義的函數(shù)。 ThreadProc. 建立的線程動態(tài)分配內(nèi)存?zhèn)鬟f信息到每個線程的實例中。線程函數(shù)負責釋放這些內(nèi)存。

            ?

            The calling thread uses the WaitForMultipleObjects function to persist until all worker threads have terminated. Note that if you were to close the handle to a worker thread before it terminated, this does not terminate the worker thread. However, the handle will be unavailable for use in subsequent function calls.

            ?

            被調(diào)用的線程用 WaitForMultipleObjects 持續(xù)等待,知道所有的工作線程退出。在線程退出后,關(guān)掉線程函數(shù)的句柄。


            #include <windows.h>
            #include <strsafe.h> //win2003 SDK必須安裝 要不無此頭文件。此文件是為了實現(xiàn)StringCchPrintf,StringCchLength。

            #define MAX_THREADS 3
            #define BUF_SIZE 255

            typedef struct _MyData {
            ??? int val1;
            ??? int val2;
            } MYDATA, *PMYDATA;

            DWORD WINAPI ThreadProc( LPVOID lpParam )
            {
            ??? HANDLE hStdout;
            ??? PMYDATA pData;

            ??? TCHAR msgBuf[BUF_SIZE];
            ??? size_t cchStringSize;
            ??? DWORD dwChars;

            ??? hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
            ??? if( hStdout == INVALID_HANDLE_VALUE )
            ??????? return 1;

            ??? // Cast the parameter to the correct data type.

            ??? pData = (PMYDATA)lpParam;

            ??? // Print the parameter values using thread-safe functions.

            ??? StringCchPrintf(msgBuf, BUF_SIZE, TEXT("Parameters = %d, %d\n"),
            ??????? pData->val1, pData->val2);
            ??? StringCchLength(msgBuf, BUF_SIZE, &cchStringSize);
            ??? WriteConsole(hStdout, msgBuf, cchStringSize, &dwChars, NULL);

            ??? // Free the memory allocated by the caller for the thread
            ??? // data structure.

            ??? HeapFree(GetProcessHeap(), 0, pData);

            ??? return 0;
            }
            ?
            void main()
            {
            ??? PMYDATA pData;
            ??? DWORD dwThreadId[MAX_THREADS];
            ??? HANDLE hThread[MAX_THREADS];
            ??? int i;

            ??? // Create MAX_THREADS worker threads.

            ??? for( i=0; i<MAX_THREADS; i++ )
            ??? {
            ??????? // Allocate memory for thread data.

            ??????? pData = (PMYDATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
            ??????????????? sizeof(MYDATA));
            ????//5);

            ??????? if( pData == NULL )
            ??????????? ExitProcess(2);

            ??????? // Generate unique data for each thread.

            ??????? pData->val1 = i;
            ??????? pData->val2 = i+100;

            ??????? hThread[i] = CreateThread(
            ??????????? NULL,????????????? // default security attributes
            ??????????? 0,???????????????? // use default stack size?
            ??????????? ThreadProc,??????? // thread function
            ??????????? pData,???????????? // argument to thread function
            ??????????? 0,???????????????? // use default creation flags
            ??????????? &dwThreadId[i]);?? // returns the thread identifier
            ?
            ??????? // Check the return value for success.
            ?
            ??????? if (hThread[i] == NULL)
            ??????? {
            ??????????? ExitProcess(i);
            ??????? }
            ??? }

            ??? // Wait until all threads have terminated.

            ??? WaitForMultipleObjects(MAX_THREADS, hThread, TRUE, INFINITE);

            ??? // Close all thread handles upon completion.

            ??? for(i=0; i<MAX_THREADS; i++)
            ??? {
            ??????? CloseHandle(hThread[i]);
            ??? }
            }

            posted on 2006-06-04 23:22 AlanTop 閱讀(6337) 評論(0)  編輯 收藏 引用 所屬分類: C++

            免费一级欧美大片久久网| 国产精品综合久久第一页| 精品久久久久久国产牛牛app| 亚洲精品乱码久久久久久蜜桃图片 | 精品人妻伦九区久久AAA片69| 久久精品国产精品亚洲艾草网美妙| 久久婷婷综合中文字幕| 国产亚洲精午夜久久久久久| 久久福利青草精品资源站| 91精品国产91热久久久久福利| 国内精品久久久久国产盗摄| 狠狠人妻久久久久久综合| 久久免费视频1| 一级做a爰片久久毛片人呢| 久久强奷乱码老熟女网站| 亚洲人成无码久久电影网站| 欧美激情精品久久久久久久九九九 | 国产精品无码久久综合网| 久久免费国产精品| 国产精品美女久久久久久2018| 精品无码久久久久久国产| 久久精品国产99国产精品亚洲| 97精品国产91久久久久久| 欧美一级久久久久久久大| 婷婷久久香蕉五月综合加勒比| 97久久精品人人做人人爽| 久久精品国产亚洲AV香蕉| www亚洲欲色成人久久精品| 久久成人国产精品免费软件| 久久国产亚洲高清观看| 久久大香萑太香蕉av| 久久香蕉国产线看观看乱码| 久久91精品久久91综合| 狠狠精品久久久无码中文字幕| 国产精品九九久久免费视频| 性做久久久久久免费观看| 久久精品www人人爽人人| 久久久噜噜噜久久中文字幕色伊伊| 99热都是精品久久久久久| 久久久久亚洲Av无码专| 久久国产欧美日韩精品|