-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunable.cpp
More file actions
49 lines (40 loc) · 989 Bytes
/
Runable.cpp
File metadata and controls
49 lines (40 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: Runable.cpp
* Author: hxw
*
* Created on September 21, 2017, 9:02 AM
*/
#include "Runable.h"
#include <unistd.h>
#include <iostream>
Runable_t::Runable_t() {
}
Runable_t::~Runable_t() {
std::cout << "~Runable_t" << task_id << std::endl;
}
void Runable_t::set_task_id(int tid) {
task_id = tid;
}
void Runable_t::run() {
std::cout << "开始执行: " << task_id << " 线程id号是: " << pthread_self() << std::endl;
usleep(1000000);
std::cout << "结束执行: " << task_id << std::endl;
destroy();
}
void Runable_t::destroy() {
delete this;
}
void Runable_t::run(void *arg) {
Runable_t *This = (Runable_t*) arg;
This->run();
return;
}
void Runable_t::destroy(void *arg) {
Runable_t *This = (Runable_t*) arg;
This->destroy();
}