#107 Half-Sync Half-Async example JavaDoc

This commit is contained in:
Ilkka Seppala 2015-08-18 22:58:00 +03:00
parent c5c4a68c6f
commit 665dc703d6
2 changed files with 16 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package com.iluwatar.halfsynchalfasync;
import java.util.concurrent.LinkedBlockingQueue;
/**
*
* This application demonstrates Half-Sync/Half-Async pattern. Key parts of the pattern are
* {@link AsyncTask} and {@link AsynchronousService}.
*
@ -44,9 +45,14 @@ import java.util.concurrent.LinkedBlockingQueue;
* Such as Priority Queue can be used as queuing layer to prioritize the way tasks are executed.
* Our implementation is just one simple way of implementing this pattern, there are many variants possible
* as described in its applications.
*
*/
public class App {
/**
* Program entry point
* @param args command line args
*/
public static void main(String[] args) {
AsynchronousService service = new AsynchronousService(new LinkedBlockingQueue<>());
/*
@ -66,6 +72,11 @@ public class App {
service.execute(new ArithmeticSumTask(1));
}
/**
*
* ArithmeticSumTask
*
*/
static class ArithmeticSumTask implements AsyncTask<Long> {
private long n;

View File

@ -4,6 +4,11 @@ import java.util.concurrent.ExecutionException;
import org.junit.Test;
/**
*
* Application test
*
*/
public class AppTest {
@Test