#107 Half-Sync Half-Async example JavaDoc
This commit is contained in:
parent
c5c4a68c6f
commit
665dc703d6
@ -3,6 +3,7 @@ package com.iluwatar.halfsynchalfasync;
|
|||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* This application demonstrates Half-Sync/Half-Async pattern. Key parts of the pattern are
|
* This application demonstrates Half-Sync/Half-Async pattern. Key parts of the pattern are
|
||||||
* {@link AsyncTask} and {@link AsynchronousService}.
|
* {@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.
|
* 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
|
* Our implementation is just one simple way of implementing this pattern, there are many variants possible
|
||||||
* as described in its applications.
|
* as described in its applications.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Program entry point
|
||||||
|
* @param args command line args
|
||||||
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
AsynchronousService service = new AsynchronousService(new LinkedBlockingQueue<>());
|
AsynchronousService service = new AsynchronousService(new LinkedBlockingQueue<>());
|
||||||
/*
|
/*
|
||||||
@ -66,6 +72,11 @@ public class App {
|
|||||||
service.execute(new ArithmeticSumTask(1));
|
service.execute(new ArithmeticSumTask(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* ArithmeticSumTask
|
||||||
|
*
|
||||||
|
*/
|
||||||
static class ArithmeticSumTask implements AsyncTask<Long> {
|
static class ArithmeticSumTask implements AsyncTask<Long> {
|
||||||
private long n;
|
private long n;
|
||||||
|
|
||||||
|
@ -4,6 +4,11 @@ import java.util.concurrent.ExecutionException;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Application test
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class AppTest {
|
public class AppTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user