I am trying to make quick sort concurrent by using threading
. But when i run the code with my threading approach, it only runs the same thread for all the partitions recursively.
Here is what I have tried.
from threading import Thread
import threading
import time
import thread
def qsort(sets,left,right):
i = left
j = right
pivot = sets[(left + right)/2]
temp = 0
while(i <= j):
while(pivot > sets[i]):
i = i+1
while(pivot < sets[j]):
j = j-1
if(i <= j):
temp = sets[i]
sets[i] = sets[j]
sets[j] = temp
i = i + 1
j = j - 1
if (left < j):
thread = Thread(target = qsort(sets,left,j))
name = threading.current_thread()
printp(sets,elements,name)
if (i < right):
thread1 = Thread(target=qsort(sets,i,right))
name = threading.current_thread()
printp(sets,elements,name)
return sets