X Tutup
Skip to content

Commit 57e702d

Browse files
committed
iluwatar#107 Double Checked Locking example JavaDoc
1 parent e71f227 commit 57e702d

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/App.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
55

66
/**
77
*
8-
* In Inventory we store the items with a given size. However, we do not store
8+
* In {@link Inventory} we store the items with a given size. However, we do not store
99
* more items than the inventory size. To address concurrent access problems we
1010
* use double checked locking to add item to inventory. In this method, the
1111
* thread which gets the lock first adds the item.
12+
*
1213
*/
1314
public class App {
1415

16+
/**
17+
* Program entry point
18+
* @param args command line args
19+
*/
1520
public static void main(String[] args) {
1621
final Inventory inventory = new Inventory(1000);
1722
ExecutorService executorService = Executors.newFixedThreadPool(3);

double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/Inventory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
import java.util.concurrent.locks.Lock;
66
import java.util.concurrent.locks.ReentrantLock;
77

8+
/**
9+
*
10+
* Inventory
11+
*
12+
*/
813
public class Inventory {
914

1015
private int inventorySize;
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package com.iluwatar.doublechecked.locking;
22

3+
/**
4+
*
5+
* Item
6+
*
7+
*/
38
public class Item {
4-
String name;
5-
int level;
9+
10+
private String name;
11+
private int level;
612
}

double-checked-locking/src/test/java/com/iluwatar/doublechecked/locking/AppTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
import com.iluwatar.doublechecked.locking.App;
66

7+
/**
8+
*
9+
* Application test
10+
*
11+
*/
712
public class AppTest {
813

914
@Test

0 commit comments

Comments
 (0)
X Tutup