0
How can i thread a function and itself in itself
The title may be confusing but how would i thread something like this def cat(): X=random.randint(0,1) if X==0: cat() This is not the code but how would i make the first cat and the cat in the function work at the same time
3 Respuestas
+ 1
create new thread for the cat function with threading module when calling it.(when calling it inside the function)
but they will never work at the same time in the example, since it stops after the function call.
0
if i coppy the same function diffrent name can i reffer to it before it is concevied
btw this is the og code
import time
from random import randint as rnum
from threading import Thread
def cell(e):
print("new cell\n")
while True:
e-=1
time.sleep(1)
e+=(rnum(0,15)/10)
if e<=0:
print("cell died")
break
if e>10:
e-=4
time.sleep(1)
cell(4)
cell(15)
0
i dont like it because it executes the next cell than executing both