Skip to content

Hesey/paralleltool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Parallel Tool

A simple and optimized tool to parallel tasks.

Use this tool like Collection.parallelStream in Java 8;

For now it supports to process List.

  • Process without Result return
List<Integer> list = Lists.newArrayList(65, 66, 67, 68, 69, 70);
ListParallel.parallel(list, new VoidProcessor<Integer>() {
	@Override
	public void process(Integer e) {
		System.out.println(e + 1);
	}
});
  • Process with Result return
List<Character> result = ListParallel.parallelWithCallback(list, new CallbackProcessor<Integer, Character>() {
	@Override
	public Character process(Integer e) {
		return (char) e.intValue();
	}
});
  • Thread Number Specify
    • When execute CPU bound task, you should use Runtime.getRuntime().availableProcessors() + 1 as thread number.
ListParallel.parallel(list, voidProcessor, Runtime.getRuntime().availableProcessors() + 1);

About

A simple and optimized tool to parallel tasks.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages