@@ -1,5 +1,6 @@
|
|||||||
|
import socket
|
||||||
import time
|
import time
|
||||||
|
|
||||||
def countdown(n):
|
def countdown(n):
|
||||||
while n > 0:
|
while n > 0:
|
||||||
print('T-minus', n)
|
print('T-minus', n)
|
||||||
@@ -12,10 +13,7 @@ t = Thread(target=countdown, args=(10,))
|
|||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
|
|
||||||
if t.is_alive():
|
print('Still running' if t.is_alive() else 'Completed')
|
||||||
print('Still running')
|
|
||||||
else:
|
|
||||||
print('Completed')
|
|
||||||
|
|
||||||
|
|
||||||
t.join()
|
t.join()
|
||||||
@@ -82,4 +80,4 @@ c.start()
|
|||||||
import multiprocessing
|
import multiprocessing
|
||||||
c = CountdownTask(5)
|
c = CountdownTask(5)
|
||||||
p = multiprocessing.Process(target=c.run)
|
p = multiprocessing.Process(target=c.run)
|
||||||
p.start()
|
p.start()
|
||||||
|
|||||||
Reference in New Issue
Block a user