how to run same function on multiple threads in pyhton

import multiprocessing

def worker(num):
    """ Worker procedure
    """
    print('Worker:', str(num))

# Mind the "if" instruction!
if __name__ == '__main__':
    jobs = [] # list of jobs
    jobs_num = 5 # number of workers
    for i in range(jobs_num):
        # Declare a new process and pass arguments to it
        p1 = multiprocessing.Process(target=worker, args=(i,))
        jobs.append(p1)
        # Declare a new process and pass arguments to it
        p2 = multiprocessing.Process(target=worker, args=(i+10,))
        jobs.append(p2)
        p1.start() # starting workers
        p2.start() # starting workers

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
excute multiple threads at the same time python run one fucntion with multiple threads in python can two threads run at the same time python how to start multiple threads at the same time in python how to run 2 functions on same thread python python run 2 threads at the same tuine python two threads to run two functions can python run multiple threads execute python script with multiple threads how to start multiple threads at the same time in pyton how to use two threads python how to run multiple threads at once python python how to run 2 threads at once python running multiple threads how to use the same function in multiple threads in python how to give a function multiple threads python multiple threads calling the same objects function simultaneously python how to run multiple threads in python python how to use multiple threads start two threads at the same time python how to run one thread multiple times in python How to run multiple threads python run multiple threads python python threading same function in different threads running multiple threads in python python start multiple threads at the same time how to do multiple threads in python python start multiple threads how to run same function from multiple threads in python python run in multiple threads python run 2 threads at the same time how to use multiple threads in python python how to run multiple threads python run multiple threads Python can execute multiple instructions simultaneously by using threads. example of running 2 threads python give more threads to a python threading using functions python python run same code on multiple threads two threads can running simultaneously in python parallel programming using python threads Which Python library runs a function as thread? which python library runs a function as thread python run same time python thread in parallel can you use two methods at the same time python start multiple threads at the same time python parallel programming using thread python running parallel threads python threading thread in parallel python python parallel threads run same function in parallel python python running multiple threads at the same time python run thread python start parallel thread threading with a function python python execute same function parallel threads python execute same function parallel multi threaded requests python python can execute multiple instructions simultaneously by using threads can i use more threads to calculate a function in python executing multiple threads simultaneously python python multiple threads calling same function python thread in function threading a function python python thread function run two threads simultaneously python running multiple threads parallely in pyhton how to run same function on multiple threads in pyhton
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source