i
cludewi
dowshr
i
cludeiostreamr
i
cludeprocesshr
i
cludecstdlibr
i
cludectimer
i
cludestri
gr
usi
g
amespacestdr
线程函数r
u
sig
edi
t__stdcallphilosophervoidr
boolthi
ki
tr
booleati
tr
voidwaiti
tr
voidpri
tr
i
tcou
t0用于记录输出的次数r
stri
gphil_state5哲学家状态(思考、等待、吃饭)r
boolstick5筷子的状态(有没有人正在使用)r
临界区结构变量r
CRITICAL_SECTIONcrout保证输出时不会竞争r
CRITICAL_SECTIONchopsticks5定义五个临界变量,代表五根筷子r
线程函数r
u
sig
edi
t__stdcallphilosophervoidkr
r
i
t
i
tk0r
sra
dtimeNULLr
whiletruer
r
thi
k
r
eat
r
r
retur
r
r
思考r
boolthi
ki
tkr
r
ifphil_statek