Giter Site home page Giter Site logo

acdirican / fifty-shades-of-multithreading Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 11 KB

How many different ways can you find to calculate the sum of an array by multi-threading? Thread, Runnable, Callable, Future, ExecutorService

Java 100.00%
callable executorservice multithreading parallel-computing parallel-programming partitioning runnable thread

fifty-shades-of-multithreading's Introduction

Fifty Shades of Multi-threading

Java provides various ways to set up a parallel program using multi-threading. Yet, multi-threading is not easy: partitioning a problem into smaller pieces, making separate threads solve them, and recombining the partial results into a final goal.

This projects both helps you to understand this process and provides you with various techniques to code it in Java, based on the simple problem of calculating the sum of the elements of a large array.

Finding the sum here is like a big job that will handled by a group of workers and, of course, a foreman.

While workers are to solve a given sub task, a forman is reponsbile of 4 important activities:

  1. Decompsing the problem into smaller parts or sub tasks
  2. Allocating sub tasks to workers
  3. Obseerving workers' progress, if necessary
  4. After workers complete their parts, recombining the sub solutions coming from the workers into a final solution.

In the implementation, the distinction will come from the partitionning of the problem (it may be iterative or recursive), the definitions of workers and forman, and the recombination of sub solutions.

Java provides a large variety of means for multi-threading. In this project, you'll find (for now) implemenations including Thread, Runnable, Callable, Future and ExecutorService, being applyed to the same problem. Thusi you will be alble to see the differences.

The project's workers (called summers) are SummerThread, SummerRunnable and SummerCallable. While SummerThread extends the Thread class, others implements Runnable and Callable interfaces, respectively. Each summer is intented to calculate the sum of the given part of an array.

ParalleSummer classes are formans of the Project. Each ParallelSummer uses a group of Summers to calculate the overall sum, either using Java ExecutorService or more conventinal means to manage the muli-threading process.

fifty-shades-of-multithreading's People

Contributors

acdirican avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.