#107 Double Checked Locking example JavaDoc

This commit is contained in:
Ilkka Seppala 2015-08-18 22:29:35 +03:00
parent e71f2279f0
commit 57e702db4f
4 changed files with 24 additions and 3 deletions

View File

@ -5,13 +5,18 @@ import java.util.concurrent.Executors;
/**
*
* In Inventory we store the items with a given size. However, we do not store
* In {@link Inventory} we store the items with a given size. However, we do not store
* more items than the inventory size. To address concurrent access problems we
* use double checked locking to add item to inventory. In this method, the
* thread which gets the lock first adds the item.
*
*/
public class App {
/**
* Program entry point
* @param args command line args
*/
public static void main(String[] args) {
final Inventory inventory = new Inventory(1000);
ExecutorService executorService = Executors.newFixedThreadPool(3);

View File

@ -5,6 +5,11 @@ import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
*
* Inventory
*
*/
public class Inventory {
private int inventorySize;

View File

@ -1,6 +1,12 @@
package com.iluwatar.doublechecked.locking;
/**
*
* Item
*
*/
public class Item {
String name;
int level;
private String name;
private int level;
}

View File

@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.doublechecked.locking.App;
/**
*
* Application test
*
*/
public class AppTest {
@Test