• <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>
            穩定盈利的期貨交易方法-量化趨勢交易

            alantop -專業量化投資者

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

            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 函數從一個進程里面創建一個線程。這個開始的線程必須指定開始執行代碼的地址,新線程執行。有代表性的,開始地址就是一個函數名。這個函數有一個參數,并且返回一個 DWORD 值。一個進程里面同時有多個線程在執行。

            ?

            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.

            下面這個例子演示如何創建一個新線程,執行本地定義的函數。 ThreadProc. 建立的線程動態分配內存傳遞信息到每個線程的實例中。線程函數負責釋放這些內存。

            ?

            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.

            ?

            被調用的線程用 WaitForMultipleObjects 持續等待,知道所有的工作線程退出。在線程退出后,關掉線程函數的句柄。


            #include <windows.h>
            #include <strsafe.h> //win2003 SDK必須安裝 要不無此頭文件。此文件是為了實現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 閱讀(6334) 評論(0)  編輯 收藏 引用 所屬分類: C++

            欧美久久久久久| 久久综合偷偷噜噜噜色| 狠狠色综合网站久久久久久久高清 | 日本免费久久久久久久网站| 久久精品aⅴ无码中文字字幕不卡| 久久久久久亚洲精品无码| 久久国产一区二区| 久久综合九色综合欧美狠狠| 91精品国产高清久久久久久io| 久久精品aⅴ无码中文字字幕重口 久久精品a亚洲国产v高清不卡 | 久久亚洲天堂| 无码人妻少妇久久中文字幕| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 亚洲愉拍99热成人精品热久久| 亚洲综合精品香蕉久久网| 久久国产高潮流白浆免费观看| 国产欧美一区二区久久| 九九久久精品无码专区| 亚洲七七久久精品中文国产| 亚洲国产精品无码久久久不卡 | 国产精品久久久香蕉| 国产亚洲精品美女久久久| 成人午夜精品久久久久久久小说| 久久青青草原精品国产不卡| 久久久久久伊人高潮影院| 国内精品久久久久久99蜜桃 | 大伊人青草狠狠久久| 香蕉99久久国产综合精品宅男自 | 一本色道久久88精品综合| 国产精品久久久久影院嫩草| 欧美激情精品久久久久久久九九九| 久久婷婷五月综合国产尤物app| 久久精品aⅴ无码中文字字幕重口| 国产精品永久久久久久久久久| 久久人人爽人人爽人人片AV不| 久久久91精品国产一区二区三区| 久久这里只有精品视频99| 狠狠色丁香久久婷婷综合五月| 亚洲欧洲久久久精品| 国产成人无码精品久久久久免费| 久久精品卫校国产小美女|