I have a problem using threading.Thread(), so I have a question.
The following simple script prints an array by looping it for:
If you run worker() as it is, it will print from 0th to 0th in the array, but
Thread (target=worker) will produce the output in reverse order.
(By the way, if the array is set to range (5000), the order may become messy.(Not sure every time)
from threading import thread
defworker():
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
for n in nums:
print n
# where the print order is 1 = > 11
worker()
# If this is the case, the order of the prints will be 11=>1.
t=Thread(target=worker)
t.start()
Is there a problem with the configuration?
Is it specific to Thread?
The environment is Windows 10, Python 2.7.
Thank you for your cooperation.
The output from logging.info was correct in order.
This post was edited based on @TatsuyaNakamori's Comment and posted as Community Wiki.I edited this post based on @TatsuyaNakamori's Comment and posted it as Community Wiki.
© 2024 OneMinuteCode. All rights reserved.