本文整理汇总了C++中Counter::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ Counter::Print方法的具体用法?C++ Counter::Print怎么用?C++ Counter::Print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Counter
的用法示例。
在下文中一共展示了Counter::Print方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
if (argc < 2) {
cout << "Not enough args ./sem <Num of threads>" << endl;
return 1;
}
sscanf(argv[1], "%d", &threadNum);
pthread_t tid[threadNum];
sem_init(&sem, 0, 1);
int returnCode;
for (int i = 0; i < threadNum; ++i) {
cout << "In main: Creating thread " << i << endl;
returnCode = pthread_create(&tid[i], NULL, ThreadRunner, NULL);
if (returnCode) {
cout << "ERROR: Return Code from pthread_create is " << returnCode << endl;
exit(-1);
}
}
for (int i = 0; i < threadNum; ++i) {
pthread_join(tid[i], NULL);
}
sem_destroy(&sem);
x.Print();
pthread_exit(NULL);
return 0;
}
示例2: main
int main(){
pthread_spin_init(&m_spinlock, 0);
pthread_t tid[THREAD_NUM];
for(int i=0;i<THREAD_NUM;i++)
pthread_create(&tid[i], NULL, ThreadRunner, 0);
for(int i=0;i<THREAD_NUM;i++)
pthread_join(tid[i], NULL);
x.Print();
return 0;
}
示例3: main
int main(){
pthread_t tid[thread_num];
int i;
for(i=0;i<thread_num;i++){
pthread_create(&tid[i], NULL, ThreadRunner, 0);
}
for(i=0;i<thread_num;i++){
pthread_join(tid[i], NULL);
}
x.Print();
return 0;
}
示例4: main
int main(){
pthread_t tid[3];
int i;
int t=100000000;
for(i=0;i<3;i++){
pthread_create(&tid[i], NULL, ThreadRunner, (void*) &t);
}
for(i=0;i<3;i++){
pthread_join(tid[i], NULL);
}
x.Print();
return 0;
}
示例5: main
int main() {
time_t start_time = time(0);
pthread_t tid[THDNUM];
sem_init(&semaphore, 0, 1);
int i;
for (i = 0; i < THDNUM; i++)
pthread_create(&tid[i], NULL, ThreadRunner, 0);
for (i = 0; i < THDNUM; i++)
pthread_join(tid[i], NULL);
cout << "Result = ";
x.Print();
cout << "duration = " << time(0) - start_time << " secs" << endl;
return 0;
}
示例6: main
int main() {
srand (time(NULL));
pthread_t tid[3];
pthread_mutex_init (&p_mutex, NULL);
for (int i = 0; i < 3;i++) {
pthread_create(&tid[i], NULL, &ThreadRunner, 0);
}
for (int i = 0; i < 3; i++){
pthread_join(tid[i], NULL);
}
pthread_mutex_destroy(&p_mutex);
x.Print();
}