Skip to content

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

License

Notifications You must be signed in to change notification settings

pablormier/parallel-loops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages