- Notifications
You must be signed in to change notification settings - Fork0
mbouchenoire/jsync
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Jsync is a lightweight Java library focused on providing simple methods to deal with concurrency before the Java 8 Stream API.This library is mostly influenced by the.NET Parallel Class andasync.js.
Call each givenRunnable asynchronously while beeing synchronous itself.You can pass as many runnables as you want usingvarargs, or even provide them within anArray /Collection.
Jsync.parallel(newRunnable() {publicvoidrun() {// Do some long task here... } },newRunnable() {publicvoidrun() {// Do some other long task there... } },newCustomRunnable(args)// or implement your own runnables);
Apply each value initems to theConsumer.Each execution ofConsumer#accept() is called asynchronously while theforEach() method itself is synchronous.
String[]strings =newString[] {"hi","jsync" };Jsync.forEach(strings,newConsumer<String>() {publicvoidaccept(Stringarg) {// each execution of this function is asynchronousSystem.out.println(arg); }});
Produces a newArray /Collection of values by mapping each value initems through theFunction.Each execution ofFunction#apply() is called asynchronously while themap() function itself is synchronous.
String[]strings =newString[] {"hi" ,"Jsync" };Integer[]lengths =Jsync.map(strings,newFunction<String,Integer>() {publicIntegerapply(Stringarg) {// each execution of this function is asynchronousreturnarg.length(); }});// lengths : [2, 5]
Produces a newArray /Collection of values which pass thePredicate test.Each execution ofPredicate#test() is called asynchronously while thefilter() function itself is synchronous.
String[]strings =newString[] {"hi","jsync","this is too long" };String[]filteredStrings =Jsync.filter(strings,newPredicate<String>() {publicBooleantest(Stringarg) {// each execution of this function is asynchronousreturn (arg.length <=10); }});// filteredStrings : [ "hi", "jsync" ]
About
Simple async utilities for Java 5+
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
