Skip to content

Commit 14af731

Browse files
author
xiang.li01
committed
make code better
1 parent c3c127c commit 14af731

File tree

6 files changed

+7
-8
lines changed

6 files changed

+7
-8
lines changed

java-lock-objects-and-atomic-variables/Readme.md

Whitespace-only changes.

java-lock-objects-and-atomic-variables/src/AtomicIntegerExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static void main(String[] args) throws InterruptedException {
2525

2626
AtomicCounter atomicCounter = new AtomicCounter();
2727

28-
for(int i = 0; i < 1000; i++) {
28+
for (int i = 0; i < 1000; i++) {
2929
executorService.submit(() -> atomicCounter.incrementAndGet());
3030
}
3131

java-lock-objects-and-atomic-variables/src/ReadWriteLockExample.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class ReadWriteCounter {
1313

1414
public int incrementAndGetCount() {
1515
lock.writeLock().lock();
16-
1716
try {
1817
count = count + 1;
1918
return count;
@@ -40,8 +39,8 @@ public static void main(String[] args) {
4039
ReadWriteCounter counter = new ReadWriteCounter();
4140

4241
Runnable readTask = () -> {
43-
System.out.println(Thread.currentThread().getName() +
44-
" Read Task : " + counter.getCount());
42+
System.out.println(Thread.currentThread().getName() +
43+
" Read Task : " + counter.getCount());
4544
};
4645

4746
Runnable writeTask = () -> {

java-lock-objects-and-atomic-variables/src/ReentrantLockExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static void main(String[] args) throws InterruptedException {
3737

3838
executorService.submit(() -> counter.increment());
3939

40-
for(int i = 0; i < 10; i++) {
40+
for (int i = 0; i < 10; i++) {
4141
executorService.submit(() -> counter.increment());
4242
}
4343

java-lock-objects-and-atomic-variables/src/ReentrantLockMethodsExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public int incrementAndGet() {
2424
throw new IllegalStateException(e);
2525
}
2626

27-
if(isAcquired) {
27+
if (isAcquired) {
2828
try {
2929
Thread.sleep(2000);
3030
count = count + 1;
@@ -46,8 +46,8 @@ public static void main(String[] args) {
4646
ReentrantLockMethodsCounter lockMethodsCounter = new ReentrantLockMethodsCounter();
4747

4848
executorService.submit(() -> {
49-
System.out.println("IncrementCount (First Thread) : " +
50-
lockMethodsCounter.incrementAndGet() + "\n");
49+
System.out.println("IncrementCount (First Thread) : " +
50+
lockMethodsCounter.incrementAndGet() + "\n");
5151
});
5252

5353
executorService.submit(() -> {

java-thread-and-runnable-examples/Readme.md

Whitespace-only changes.

0 commit comments

Comments
 (0)