from threading import *
def myfunc(i,name):
print("This is " + str(name))
for i in range(4):
name = current_thread().name
t = Thread(target=myfunc, args=(i,name,))
t.start()
current_thread().getName() also gives same results.I was wondering is this the way it works or is it running the same thread,so it is passing the the name MainThread?
Output :
This is MainThread
This is MainThread
This is MainThread
This is MainThread
name = current_thread().nameYou're always checking the name of the current thread, which is the main thread. You need to checkt.name.MainThread