text: from concurrent import futures
  import math
  import sys
  
  def calc(val):
      result = math.sqrt(float(val))
      return val, result
  
  def use_threads(num, values):
      with futures.ThreadPoolExecutor(num) as tex:
          tasks = [tex.submit(calc, value) for value in values]
          for f in futures.as_completed(tasks):
               yield f.result()
  
  def use_processes(num, values):
      with futures.ProcessPoolExecutor(num) as pex:
          tasks = [pex.submit(calc, value) for value in values]
          for f in futures.as_completed(tasks):
               yield f.result()
  
  def main(workers, values):
      print(f"Liczba wywołań: {workers}, liczba wartości: {len(values)}")
      print("Wątki:")
      for val, result in use_threads(workers, values):
          print(f'{val} {result:.4f}')
      print("Procesy:")
      for val, result in use_processes(workers, values):
          print(f'{val} {result:.4f}')
  
  if __name__ == '__main__':
      workers = 3
      if len(sys.argv) > 1:
          workers = int(sys.argv[1])
      values = list(range(1, 6)) # 1 .. 5
      main(workers, values)
  