I want to call this function with different threads each containing different values from the loop. The result and how I want it is shown below. As is my script.
Result with (3) Threads
Checking Data x
Checking Data x
Checking Data x
Checking Data y
Checking Data y
Checking Data y
Checking Data z
Checking Data z
Checking Data z
What i want with (3) Threads
Checking Data x
Checking Data y
Checking Data z
My script:
from threading import Thread #Imports
def checker(urls):
print(f"Checking Data {urls}")
threads = []
urls = open("links.txt", "r").readlines() # loading And reading textfile lines
urls = (linez.replace("\n", "")for linez in urls)
for linez in urls: # First Loop
# Data Below is to be sent to threads
data = linez
#Data Above is to be sent to threads
for i in range(3): #Second Loop Inside First Loop
process = Thread(target=checker, args=[data])
process.start()
threads.append(process)
for x in threads: #Third Alone xD Loop
x.join()