0

what is thread in python programming?

what is threading is?

27th Oct 2019, 12:47 AM
Muhammad Saleh Alatas
Muhammad Saleh Alatas - avatar
1 Answer
0
Threads are used in python for parallel computing. Consider this snippet: fun1(arg1) fun2(arg2) By default, in python, fun2 will be exectuted only after fun1 completes its execution. But suppose you need to call both of them simultaneously. How will you do it? Threads are for this. The problem in the above code can be solved by: from threading import Thread x = Thread(target=fun1, args=(arg1)) y = Thread(target=fun2, args=(arg2)) This creates two threads and the targets of both the threads are executed simultaneously. This is the use of threading.
29th Oct 2019, 7:53 AM
Jalaj Kumar
Jalaj Kumar - avatar