Skip to main content

MultiThreading: Thread + Queue

Project description

Multi Threading

Example Class

import multithreading

class Demo(multithreading.MultiThread):
    def task(self, task):
        print(task)

Example Main

task_list = range(1, 3 + 1)

demo = Demo(task_list, threads=3)

# Start
demo.start()

Result

1
2
3

OR

demo = Demo(threads=3)

# Start threads
demo.start_threads()

# Adding task to queue
demo.add_task(1)
demo.add_task(2)
demo.add_task(3)

# Wait until queue is empty
demo.join()

Result

1
2
3

Install

$ pip install multithreading

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multithreading-0.1.7.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

multithreading-0.1.7-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page