title: Multi threading not executing Tasks simultaneously
body: <p>I wrote a python code for my project that stores file name of files on the SFTP server in a list and does the same for local directory and compares the 2 lists and then download the uncommon files. code takes its server credentials from a separate text file of format </p>
  
  <p>CONTENTS OF TEXT FILE (config9.txt)</p>
  
  <pre><code>127.0.0.1,username,password,log22.txt,/new45,C:\Users\udit\Desktop\ftp2\bob16
  </code></pre>
  
  <p>my program executed one by one for different IP's. I wanted it to run it parallely for all IP's using multithreading. I modified my code but it still executes it one by one. Whats the error in it?</p>
  
  <pre><code>import os
  import pysftp
  import csv
  import socket
  from stat import S_IMODE, S_ISDIR, S_ISREG
  import time
  import threading
  from threading import Thread
  from time import sleep
  import os.path
  import shutil
  import fileinput
  import lock
  
  cnopts = pysftp.CnOpts()
  cnopts.hostkeys = None
  
  def mainprocess():
      with open("config9.txt", "r") as csv_file:
          csv_reader = csv.reader(csv_file, delimiter=',')
          for row in csv_reader:
              print(row)
              IP=row[0]
              myUsername=row[1]
              myPassword=row[2]
              txtfile=row[3]
              remotepath=row[4]
              localpath=row[5]
  
              with pysftp.Connection(host=IP, username=myUsername, password=myPassword, cnopts=cnopts) as sftp:
                  r = str(socket.gethostbyaddr(IP))
                  print("connection successful with " + r)
  
  
                  def get_file2(sftp, remotedir):
                      result = []
                      for entry in sftp.listdir_attr(remotedir):
                          remotepath = remotedir + "/" + entry.filename
                          mode = entry.st_mode
                          if S_ISDIR(mode):
                              result += get_file2(sftp, remotepath)
                          elif S_ISREG(mode):
                              if (time.time() - entry.st_mtime) // (24 * 3600) &gt; 0:
                                  result.append(entry.filename)
  
                      return result
  
  
                  remote_path = remotepath
                  d = get_file2(sftp, remote_path)
  
  
                  def process():
                      myName = []
                      with open(filename, 'r+') as f:
                          for name in f.readlines():
                              while '\n' in name:
                                  name = name.replace('\n', '')
                                  myName.append(name)
                      print(myName)
                      print(len(myName))
  
                      import os
  
                      filtered_list = [string for string in d if string not in myName]
                      print("filtered list:", filtered_list)
                      print(len(filtered_list))
  
                      local_path =localpath
  
                      def compare_files(sftp, remotedir, remotefile, localdir, preserve_mtime=True):
                          remotepath = remotedir + "/" + remotefile
                          localpath = os.path.join(localdir, remotefile)
                          mode = sftp.stat(remotepath).st_mode
                          if S_ISDIR(mode):
                              try:
                                  os.mkdir(localpath, mode=777)
                              except OSError:
                                  pass
                              compare_files(sftp, remotepath, localpath, preserve_mtime)
                          elif S_ISREG(mode):
                              sftp.get(remotepath, localpath, preserve_mtime=True)
  
                      for file in filtered_list:
                          compare_files(sftp, remote_path, file, local_path, preserve_mtime=False)
  
                      with open(filename, 'a') as f:
                          for item in filtered_list:
                              f.write("%s\n" % item)
  
  
                  filename=txtfile
                  try:
                      file = open(filename, 'r')
                      process()
                  except IOError:
                      file = open(filename, 'w')
                      process()
  
  
  
  t=time.time()
  
  t1=threading.Thread(target=mainprocess(),args=())
  t1.start()
  
  t1.join()
  </code></pre>