Skip to content

Instantly share code, notes, and snippets.

Created Oct 14, 2019
What would you like to do?
Linkedin parseq. Run task after task in Parallel and print the responsebody length.
package FormingGroup;
import com.linkedin.parseq.Engine;
import com.linkedin.parseq.EngineBuilder;
import com.linkedin.parseq.Task;
import com.linkedin.parseq.httpclient.HttpClient;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
public class InputClass {
private static Task<Integer> fetchBody(String url) {
Task<Integer> map = HttpClient.get(url).task().map("map content to length", content -> content.getResponseBody().length());
return map;
public static void main(String[] args) {
final int numCores = Runtime.getRuntime().availableProcessors();
final ExecutorService taskScheduler = Executors.newFixedThreadPool(numCores + 1);
final ScheduledExecutorService timerScheduler = Executors.newScheduledThreadPool(numCores + 1);
final Engine engine = new EngineBuilder()
final Task<Integer> stackOverFlow = fetchBody("");
final Task<Integer> google = fetchBody("");
final Task<Integer> ethereum = fetchBody("");
final Task<String> plan = Task.par(stackOverFlow, google, ethereum)
.map((s, g, e) -> "Google Page: " + s + " \n" +
"Yahoo Page: " + g + "\n" +
"Bing Page: " + e + "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment