Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import math #importing library for the code
from time import time
import threading
from time import time,sleep
from threading import Lock
t0 = time() #stating time
values= [12,20,4,100,64,77,200,9,10] # array to be calulated
def mycosine(n): #funtion for calculating cosie
return math.cos(n)
def concurrent_cosines(): #functionn for printing cosine functions
sleep(1)
for val in values:
res = mycosine(val)
print('Cosine of %s is %s' % (val,res), '\n')
sleep(1)
t = threading.Thread(target=concurrent_cosines)
t2 = threading.Thread(target=concurrent_cosines)
t3= threading.Thread(target=concurrent_cosines)
t.start()
t2.start()
t3.start()
t.join()
t2.join()
t3.join()
print("total time taken:"+str(time()-t0))