#107 Thread Pool JavaDoc
This commit is contained in:
parent
fde7f71704
commit
0bda2bda1e
@ -13,14 +13,19 @@ import java.util.concurrent.Executors;
|
|||||||
* more tasks than threads. As soon as a thread completes its task, it will request the next
|
* more tasks than threads. As soon as a thread completes its task, it will request the next
|
||||||
* task from the queue until all tasks have been completed. The thread can then terminate, or
|
* task from the queue until all tasks have been completed. The thread can then terminate, or
|
||||||
* sleep until there are new tasks available.
|
* sleep until there are new tasks available.
|
||||||
*
|
* <p>
|
||||||
* In this example we create a list of tasks presenting work to be done. Each task is then
|
* In this example we create a list of tasks presenting work to be done. Each task is then
|
||||||
* wrapped into a Worker object that implements Runnable. We create an ExecutorService with
|
* wrapped into a {@link Worker} object that implements {@link Runnable}. We create an
|
||||||
* fixed number of threads (Thread Pool) and use them to execute the Workers.
|
* {@link ExecutorService} with fixed number of threads (Thread Pool) and use them to execute
|
||||||
|
* the {@link Worker}s.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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 ) {
|
||||||
|
|
||||||
System.out.println("Program started");
|
System.out.println("Program started");
|
||||||
|
@ -2,7 +2,7 @@ package com.iluwatar.threadpool;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Worker implements Runnable and thus can be executed by ExecutorService
|
* Worker implements {@link Runnable} and thus can be executed by {@link ExecutorService}
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Worker implements Runnable {
|
public class Worker implements Runnable {
|
||||||
|
@ -4,6 +4,11 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import com.iluwatar.threadpool.App;
|
import com.iluwatar.threadpool.App;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application test
|
||||||
|
* @author ilkka
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class AppTest {
|
public class AppTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user