上一页 1 ··· 33 34 35 36 37 38 39 40 41 ··· 92 下一页
HANDLE hMutex;int main(){ hMutex = CreateMutex(NULL,TRUE,TEXT("tickets")); if(hMutex){ if(GetLastError()== ERROR_ALREADY_EXISTS){ cout<<"已存在运行实例"<<endl; system("pause"); return 0; } } 互斥对象(Mutex)、事件对象(Event) 与 关键代码段(CriticalSection) 的比较1.互斥对象和事件对象都属于内核对象,利用内 Read More
posted @ 2012-03-24 16:26 庚武 Views(448) Comments(0) Diggs(0) Edit
#include <windows.h>#include <iostream>using namespace std;DWORD WINAPI MyThreadProc1(LPVOID lpParameter); //thread dataDWORD WINAPI MyThreadProc2(LPVOID lpParameter);int tickets=100;CRITICAL_SECTION g_cs;int main(){ DWORD tid1=0,tid2=0; HANDLE handle1 = CreateThread(NULL,0,MyThreadProc1 Read More
posted @ 2012-03-24 15:55 庚武 Views(339) Comments(0) Diggs(0) Edit
为了实现线程间的同步,不应该使用人工重置的事件对象,而应该使用自动重置的事件对象。g_hEvent = CreateEvent(NULL,FALSE,TRUE,NULL);注意区分人工重置事件对象和自动重置事件对象。当人工重置的事件对象得到通知时,等待该事件对象的所有线程均变为可调度线程,操作系统不会将该事件对象设置为无信息状态,需要显式地调用ResetEvent函数将其设置为无信号状态,否则该对象一直是有信号状态。当一个自动重置的事件对象得到通知时,等待该事件对象的线程中只有一个线程变为可调度线程,同时操作系统会将该事件对象设置无信号状态,这样,当对所保护的代码的执行完成后,需要调用SetE Read More
posted @ 2012-03-24 10:22 庚武 Views(332) Comments(0) Diggs(0) Edit
#include <windows.h>#include <iostream>using namespace std;DWORD WINAPI MyThreadProc1(LPVOID lpParameter); //thread dataDWORD WINAPI MyThreadProc2(LPVOID lpParameter);DWORD WINAPI MyThreadProc3(LPVOID); //thread dataDWORD WINAPI MyThreadProc4(LPVOID);int tickets=100;HANDLE hMutex;int mai Read More
posted @ 2012-03-23 18:30 庚武 Views(225) Comments(0) Diggs(0) Edit
#include <iostream>using namespace std;class A{public: int m_a; A(int a):m_a(a){ cout<<"A 构造"<<endl; } void introA(){ cout<<"m_a:"<<m_a<<endl; }};class B1:public A{public: int m_b1; B1(int a,int b1):A(a),m_b1(b1){ cout<<"B1 构造"& Read More
posted @ 2012-03-23 01:01 庚武 Views(325) Comments(0) Diggs(0) Edit
该文被密码保护。 Read More
posted @ 2012-03-21 18:11 庚武 Views(1) Comments(0) Diggs(0) Edit
http://www.rdlt.com/multiple-memcache-instancesservers-on-windows.html安装:sc create "Memcached11200" binPath= "C:\Users\Administrator\Desktop\memcached\memcached.exe -d runservice -p 11200 -m 32" DisplayName= "Memcached11200" start= auto删除:sc deleteMemcached11200 Read More
posted @ 2012-03-19 16:39 庚武 Views(275) Comments(0) Diggs(0) Edit
void CMenuView::OnRButtonDown(UINT nFlags, CPoint point) { //弹出菜单 /* CMenu menu; menu.LoadMenu(IDR_MENU_POPUP); CMenu *pMenu = menu.GetSubMenu(0); //ScreenToClient(&point); ClientToScreen(&point); pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,this); */ CView::OnR Read More
posted @ 2012-03-17 12:34 庚武 Views(788) Comments(0) Diggs(0) Edit
// crt_sprintf.c// compile with: /W3// This program uses sprintf to format various// data and place them in the string named buffer.#include <stdio.h>int main( void ){ char buffer[200], s[] = "computer", c = 'l'; int i = 35, j; float fp = 1.7320534f; // Format and print vario Read More
posted @ 2012-03-16 15:47 庚武 Views(834) Comments(0) Diggs(0) Edit
Move commandsk up linej down line beginning of next linel right space right spaceh left space left spacew word forwardW word forward, ignore punctuatione end of wordE end of word, ignore punctuationb word backwardB word backward, ignore punctuation0 beginning of line^ first non-whitespace charac... Read More
posted @ 2012-03-16 14:16 庚武 Views(289) Comments(0) Diggs(0) Edit
上一页 1 ··· 33 34 35 36 37 38 39 40 41 ··· 92 下一页