B
B
Brandon19982020-05-18 16:51:49
Python
Brandon1998, 2020-05-18 16:51:49

How can Thread be replaced in code?

There is code that starts two threads, but the question is - how can you get the same result, but without using "Thread"?

THE CODE:

from threading import Thread
a = int(input())
b = int(input())
def flow1(a,b):
    for i in range(100):
        a = (a+10)
        b = (b-5)
        print("Поток 1:", "a =", a, "b =", b)
def flow2(b):
    for i in range(100):
        b = (b+5)
        print("Поток 2:", "b =", b)

thread1 = Thread(target=flow1, args=(a, b,))
thread2 = Thread(target=flow2, args=(b,))

thread1.start()
thread2.start()
thread1.join()
thread2.join()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question