python - Pausing entire program from a thread spawned from a thread -


my program looks this:

from threading import thread import time  def something():     time.sleep(10)  def function1():     if condition1:         thread(target=something).start()   def function2():     if condition2:         thread(target=something).start()  def function3():     if condition3:         thread(target=something).start()  def main():     thread(target=function1).start()     thread(target=function2).start()     thread(target=function3).start()  main() 

if function 1 has spawned thread calling something() ,i dont want functions 2 , 3 spawn thread calling something().

actually code creates 3 independent threads , each of these threads can create thread doing something, again independent of each other (so getting 3 soemthing threads @ max). ask these threads interact in manner: "something" should executed once. hence thread "something" must instantiated 1 time , call must secured lock. function threads must know "something" thread, need create "something" thread in main() , pass function threads. in not sure give simple program structure , might revise want achieve.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -