Message361622
================================================================
import threading
import time
def threadFunc():
while True:
print('new thread')
time.sleep(2)
def main():
th = threading.Thread(target=threadFunc())
th.start()
while True:
print('main Thread')
time.sleep(1)
th.join()
if __name__ == '__main__':
main()
==============================================================
When I run the above code in python 3.7, it works in unexpected way.
I expected this code causes an syntax error for giving an improper argument to parameter because I gave "threaFunc()" not "threaFun" as an argument of target in Thread class. However, this code executes a function "threadFunc()" as a general function not thread. |
|
Date |
User |
Action |
Args |
2020-02-08 09:55:36 | 임수진학부생 | set | recipients:
+ 임수진학부생, paul.moore, tim.golden, zach.ware, steve.dower |
2020-02-08 09:55:36 | 임수진학부생 | set | messageid: <1581155736.57.0.784199472147.issue39581@roundup.psfhosted.org> |
2020-02-08 09:55:36 | 임수진학부생 | link | issue39581 messages |
2020-02-08 09:55:36 | 임수진학부생 | create | |
|