from
os
import
cpu_count
from
time
import
strftime, sleep
from
multiprocessing
import
Process, freeze_support
def
full():
number
=
0
while
True
:
if
number >
10000
:
number
=
0
number
+
=
1
def
showTime():
while
True
:
print
(f
'\r本地时间:{strftime("%Y-%m-%d %H:%M:%S")}'
, end
=
'', flush
=
True
)
sleep(
1
)
if
__name__
=
=
'__main__'
:
freeze_support()
kernel
=
cpu_count()
print
(f
'CPU 暖手器已开启 {kernel} 个核心'
)
pro
=
[Process(target
=
full, daemon
=
True
)
for
n
in
range
(kernel)]
for
p
in
pro: p.start()
showTime()
for
p
in
pro: p.join()