multithreading - Summing numbers using Threads -


the code gives me error..what iam doing wrong here

 #!/usr/bin/env python3  datetime import datetime  max_num = 10000 numprocs = 1    # threading multiprocessing import process, queue  start_time = datetime.now()   def sum_range(start,stop,out_q): = start counter = 0 while < stop: counter += i += 1 out_q.put(counter)  mysums = queue() mybounds = [1+i in range(0,max_num+1,int(max_num/numprocs))] myprocs = []  in range(numprocs): p = process(target=sum_range, args=(mybounds[i],mybounds[i+1],mysums)) p.start() myprocs.append(p)  mytotal = 0 in range(numprocs): mytotal += mysums.get()  in range(numprocs):    myprocs[i].join() print(mytotal) end_time =datetime.now() print('time taken : {}'. format(end_time-start_time)) 

was trying make make thread code sums numbers.it gives me error below if name == 'main': freeze_support() ...

    "freeze_support()" line can omitted if program     not going frozen produce executable. 


Comments