Answer the question
In order to leave comments, you need to log in
Is it possible to change the main loop variable from a thread?
Good day. I have a script that works like this:
1. Infinite Loop
1.1. Execution of function #1, which changes the value of the variable to True/False.
1.2 If True, then I perform function No. 2.
My task is to call function #2 as often as possible. After some thought, I decided that if function #1 is moved to a separate thread, then function #2 will be called more often, because it does not wait for function #1 to be executed. But how can I change the main loop variable in the thread that executes function #1, where function #2 is located?
PS I know that python and speed are a dubious duo, but still. If you have other options for increasing the frequency of the function call # 2, I will be glad to get acquainted with them.
Answer the question
In order to leave comments, you need to log in
Threads share a single address space, so that they share variables, there is no problem with changing them.
PS Python and speed are commonplace. Statements to the contrary are questionable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question