线程池的计时器
2012-09-27 22:17
148 查看
#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
void CALLBACK TimeoutCallback(PTP_CALLBACK_INSTANCE, PVOID pvContext, PTP_TIMER pTimer)
{
long* count = (long*)pvContext;
InterlockedIncrement(count);
cout << GetCurrentThreadId() << "," << *count << 's' << endl;
}
void WaitForKeyboard()
{
while(!_kbhit());
}
void main()
{
PTP_TIMER pTimer = NULL;
long local = 0;
pTimer = CreateThreadpoolTimer(&TimeoutCallback, &local, NULL);
FILETIME ft = {-1, 0};
SetThreadpoolTimer(pTimer, &ft, 100, 0);
WaitForKeyboard();
}
#include <conio.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
void CALLBACK TimeoutCallback(PTP_CALLBACK_INSTANCE, PVOID pvContext, PTP_TIMER pTimer)
{
long* count = (long*)pvContext;
InterlockedIncrement(count);
cout << GetCurrentThreadId() << "," << *count << 's' << endl;
}
void WaitForKeyboard()
{
while(!_kbhit());
}
void main()
{
PTP_TIMER pTimer = NULL;
long local = 0;
pTimer = CreateThreadpoolTimer(&TimeoutCallback, &local, NULL);
FILETIME ft = {-1, 0};
SetThreadpoolTimer(pTimer, &ft, 100, 0);
WaitForKeyboard();
}
相关文章推荐
- 线程池计时器
- Windows phone手机开发之图片选择器,照相机功能,计时器,加速度,图片路径问题,页面间传值,随机产生数字
- Android中的线程和线程池
- 线程池中如何确定线程的数目
- Tomcat源码分析(三)------ 可携带状态的线程池
- node源码详解(七) —— 文件异步io、线程池【互斥锁、条件变量、管道、事件对象】
- java多线程&线程池
- Java 理论与实践: 线程池与工作队列
- HTML5 canvas 计时器
- Java 自带四种线程池的使用
- 使用线程池打印出1-1000
- 游戏服务端线程池设计技巧——无锁处理玩家请求
- java常用的几种线程池比较
- 2013-6-28-3-js计时器
- Android AsyncTask原理以及线程池概念
- java线程池(一) 简述线程池的几种使用方式
- ExecutorService线程池
- 深入理解Java之线程池(下)
- java-源码解读-线程池提交之execute和submit有何不同
- Handler+ExecutorService(线程池)+MessageQueue模式+缓存模式