import random,time
from threading import Thread
usleep = lambda x: time.sleep(x/1000000.0)
def getcode(numbers):
data = '{"code":"'+ str(numbers) +'}'
print(data)
inputNumbers =range(1,10)
randomize = random.sample(inputNumbers, 9)
THREAD_COUNT = 2
for numbers in randomize:
for _ in range(THREAD_COUNT):
proc = Thread(target=getcode, args=[numbers])
usleep(10000)
proc.start()
i need to generate non repeating number from 1 to 10 with multithreading them . but it alwayes gives multiple same values duo to threading .
Aucun commentaire:
Enregistrer un commentaire