GithubHelp home page GithubHelp logo

gregdyke / parallel-loops Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pablormier/parallel-loops

0.0 1.0 0.0 108 KB

Simple & Lightweight library for Java to assist the creation of concurrent tasks and loop parallelization.

License: Other

Java 100.00%

parallel-loops's Introduction

parallel-loops Build Status Coverage Status

Very simple & lightweight util class for Java to assist the creation of concurrent tasks and loop parallelization. You can use this library to process collections in parallel just using very few lines. If you need something more powerful, I recommend you to check the functionaljava project which provides high-order concurrency abstractions http://code.google.com/p/functionaljava/.

Example

Transform a set of words to upper case in parallel:

Collection<String> upperCaseWords = 
        Parallel.ForEach(words, new Parallel.F<String, String>() {
            public String apply(String s) {
                return s.toUpperCase();
            }
        });

Transform a set of words to upper case but using no more than 4 threads:

Collection<String> upperCaseWords = 
            new Parallel.ForEach<String, String>(words)
                .withFixedThreads(4)
                .apply(new Parallel.F<String, String>() {
                    public String apply(String s) {
                        return s.toUpperCase();
                    }
                }).values();

Usage

If you use Maven, just paste the following snippet into your pom.xml:

<dependency>
    <groupId>es.usc.citius.common</groupId>
    <artifactId>parallel-loops</artifactId>
    <version>1.0</version>
</dependency>

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.