I recently started to study threads and I know it is about multiple processing stuff I just don't get why this is happening
import threading
class BuckyMessenger(threading.Thread):
def __init__(self, name):
threading.Thread.__init__(self)
print("test")
def run(self):
for _ in range(4):
print(threading.current_thread().getName())
x = BuckyMessenger(name='Send')
y = BuckyMessenger(name='Receive')
z = BuckyMessenger(name='Nothing')
x.start()
y.start()
z.start()
I Expected this to happen:
test
Send
test
Receive
test
Nothing
from here on, I should have gotten 9 more prints of 3 random "Send" and 3 random "Receive" and 3 Random "Nothing", like the following: (rest of the results)
Send
Receive
Nothing
Nothing
Nothing
Send
Receive
Receive
send
But this is the result I got: I mean why? why python acts this way?
test
test
test
Thread-1
Thread-1
Thread-1
Thread-1
Thread-2
Thread-2
Thread-2
Thread-2
Thread-3
Thread-3
Thread-3
Thread-3