Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Parallel Programming with Python

You're reading from  Parallel Programming with Python

Product type Book
Published in Jun 2014
Publisher
ISBN-13 9781783288397
Pages 124 pages
Edition 1st Edition
Languages

Table of Contents (16) Chapters

Parallel Programming with Python
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
1. Contextualizing Parallel, Concurrent, and Distributed Programming 2. Designing Parallel Algorithms 3. Identifying a Parallelizable Problem 4. Using the threading and concurrent.futures Modules 5. Using Multiprocessing and ProcessPoolExecutor 6. Utilizing Parallel Python 7. Distributing Tasks with Celery 8. Doing Things Asynchronously Index

Using threading to obtain the Fibonacci series term with multiple inputs


Now it is time for the truth. The mission is to parallelize the execution of the terms of the Fibonacci series when multiple input values are given. For didactical purposes, we will fix the input values in the four elements and the four threads to process each element, simulating a perfect symmetry among workers and tasks to be executed. The algorithm will work as follows:

  1. First, a list will store the four values to be calculated and the values will be sent into a structure that allows synchronized access of threads.

  2. After the values are sent to the synchronized structure, the threads that calculate the Fibonacci series need to be advised that the values are ready to be processed. For this, we will use a thread synchronization mechanism called Condition. (The Condition mechanism is one of the Python objects that offer data access synchronization mechanisms shared among threads; you can learn more at http://docs.python...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}