解决线程使用sleep或usleep等函数导致整个进程睡眠的问题:
获取当前时间的秒数
/*
author : kj
time : 2013-12-06 21:36
instruction:
get the num of the current seconds
*/
int get_current_time_second(void)
{
struct tm *tmnow;
struct timeval tv;
gettimeofday(&tv,NULL);
tmnow = localtime(&tv.tv_sec);
return tv.tv_sec;
}
使用下面的函数接口完成替换线程中sleep计时
/*
author : kj
time : 2013-12-06 21:42
function :
done the function of time interval in separate thread
*/
int pthread_count_second(int time_interval)
{
int current_seconds = 0;
int execl_seconds =