Skip to content

Commit 77f8f4c

Browse files
github-actionsgithub-actions
github-actions
authored and
github-actions
committed
Formatted with Google Java Formatter
1 parent 64bed62 commit 77f8f4c

19 files changed

+66
-64
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
package com.examplehub.basics.thread;
22

3-
import java.util.concurrent.Callable;
43

5-
public class CallableExample {
6-
}
4+
public class CallableExample {}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
package com.examplehub.basics.thread;
22

3-
public class DaemonThread {
4-
}
3+
public class DaemonThread {}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
package com.examplehub.basics.thread;
22

3-
public class ExampleRunnable{
4-
}
3+
public class ExampleRunnable {}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
package com.examplehub.basics.thread;
22

3-
public class ExampleThread {
4-
}
3+
public class ExampleThread {}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
package com.examplehub.basics.thread;
22

3-
public class JoinThread {
4-
}
3+
public class JoinThread {}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
package com.examplehub.basics.thread;
22

3-
public class PriorityOfThread {
4-
5-
}
3+
public class PriorityOfThread {}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
package com.examplehub.basics.thread;
22

3-
public class SleepExample {
4-
}
3+
public class SleepExample {}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
package com.examplehub.basics.thread;
22

3-
public class StopThread {
4-
}
3+
public class StopThread {}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
package com.examplehub.basics.thread;
22

3-
public class TakeMoneyFromAccountExample {
4-
}
3+
public class TakeMoneyFromAccountExample {}

src/test/java/com/examplehub/basics/thread/CallableExampleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.examplehub.basics.thread;
22

3-
import java.util.concurrent.*;
3+
import static org.junit.jupiter.api.Assertions.*;
44

5+
import java.util.concurrent.*;
56
import org.junit.jupiter.api.*;
67
import org.junit.jupiter.api.Test;
7-
import static org.junit.jupiter.api.Assertions.*;
88

99
class CallableExampleTest {
1010

src/test/java/com/examplehub/basics/thread/DaemonThreadTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
package com.examplehub.basics.thread;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.junit.jupiter.api.Assertions.assertEquals;
64
import static org.junit.jupiter.api.Assertions.assertTrue;
75

6+
import org.junit.jupiter.api.Test;
7+
88
class DaemonThreadTest {
99
@Test
1010
void test() {
1111
class ExampleThread extends Thread {
1212
@Override
1313
public void run() {
1414
assertTrue(Thread.currentThread().isDaemon());
15-
while (true) {
16-
}
15+
while (true) {}
1716
}
1817
}
1918
ExampleThread thread = new ExampleThread();

src/test/java/com/examplehub/basics/thread/ExampleRunnableTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ class ExampleRunnableTest {
99
void testRunnable() throws InterruptedException {
1010
class ExampleRunnable implements Runnable {
1111
private int sum = 0;
12+
1213
@Override
1314
public void run() {
1415
for (int i = 1; i <= 100; ++i) {
1516
sum = sum + i;
1617
}
1718
}
19+
1820
public int getSum() {
1921
return sum;
2022
}

src/test/java/com/examplehub/basics/thread/ExampleThreadTest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class ExampleThreadTest {
99
@Test
10-
void test() throws Exception{
10+
void test() throws Exception {
1111
class ExampleThread extends Thread {
1212
private int sum = 0;
1313

@@ -34,14 +34,14 @@ void testAnonymous() {
3434
}
3535

3636
@Test
37-
@Disabled //TODO build fail on gradle platform
37+
@Disabled // TODO build fail on gradle platform
3838
void testGetThreadId() {
39-
new Thread(()->assertTrue(Thread.currentThread().getId() > 1)).start();
39+
new Thread(() -> assertTrue(Thread.currentThread().getId() > 1)).start();
4040
assertEquals(1, Thread.currentThread().getId());
4141
}
4242

4343
@Test
44-
@Disabled //TODO build fail on gradle platform
44+
@Disabled // TODO build fail on gradle platform
4545
void testGetThreadName() {
4646
class ExampleThread extends Thread {
4747
public ExampleThread(String name) {
@@ -54,7 +54,10 @@ public void run() {
5454
}
5555
}
5656
new ExampleThread("sub-thread").start();
57-
new Thread(() -> assertEquals("second-sub-thread", Thread.currentThread().getName()), "second-sub-thread").start();
57+
new Thread(
58+
() -> assertEquals("second-sub-thread", Thread.currentThread().getName()),
59+
"second-sub-thread")
60+
.start();
5861
assertEquals("main", Thread.currentThread().getName());
5962
}
6063

src/test/java/com/examplehub/basics/thread/PriorityOfThreadTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package com.examplehub.basics.thread;
22

3-
import org.junit.jupiter.api.Test;
43
import static org.junit.jupiter.api.Assertions.*;
54

5+
import org.junit.jupiter.api.Test;
6+
67
class PriorityOfThreadTest {
78
@Test
89
void test() {
9-
Thread thread = new Thread(()->{
10-
assertEquals(Thread.MAX_PRIORITY, Thread.currentThread().getPriority());
11-
});
10+
Thread thread =
11+
new Thread(
12+
() -> {
13+
assertEquals(Thread.MAX_PRIORITY, Thread.currentThread().getPriority());
14+
});
1215
thread.setPriority(Thread.MAX_PRIORITY);
1316
thread.start();
1417
}
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
package com.examplehub.basics.thread;
22

3-
import org.junit.jupiter.api.Test;
3+
import static org.junit.jupiter.api.Assertions.*;
44

55
import java.text.SimpleDateFormat;
6-
import java.time.LocalDateTime;
76
import java.util.Date;
8-
9-
import static org.junit.jupiter.api.Assertions.*;
7+
import org.junit.jupiter.api.Test;
108

119
class SleepExampleTest {
1210
@Test
1311
void testClockMonitor() throws InterruptedException {
14-
new Thread(() -> {
15-
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
16-
while (true) {
17-
Date date = new Date();
18-
System.out.println(sdf.format(date));
19-
try {
20-
Thread.sleep(1000);
21-
} catch (InterruptedException e) {
22-
e.printStackTrace();
23-
}
24-
}
25-
}).start();
12+
new Thread(
13+
() -> {
14+
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
15+
while (true) {
16+
Date date = new Date();
17+
System.out.println(sdf.format(date));
18+
try {
19+
Thread.sleep(1000);
20+
} catch (InterruptedException e) {
21+
e.printStackTrace();
22+
}
23+
}
24+
})
25+
.start();
2626
Thread.sleep(1000); // set bigger argument to see effect
2727
}
28-
}
28+
}

src/test/java/com/examplehub/basics/thread/StateOfThreadTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class StateOfThreadTest {
99
@Test
10-
@Disabled //TODO
10+
@Disabled // TODO
1111
void test() {
1212
Thread thread = new Thread(new StateOfThread());
1313
assertEquals(Thread.State.NEW, thread.getState());

src/test/java/com/examplehub/basics/thread/StopThreadTest.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
package com.examplehub.basics.thread;
22

3-
import org.junit.jupiter.api.Test;
43
import static org.junit.jupiter.api.Assertions.*;
4+
5+
import org.junit.jupiter.api.Test;
6+
57
class StopThreadTest {
68
@Test
79
void test() throws InterruptedException {
810
class ExampleThread extends Thread {
911
private boolean stopped = false;
12+
1013
@Override
1114
public void run() {
12-
while (!stopped) {
13-
}
14-
assertThrows(ArithmeticException.class, ()->{
15-
int num = 10 / 0;
16-
});
15+
while (!stopped) {}
16+
assertThrows(
17+
ArithmeticException.class,
18+
() -> {
19+
int num = 10 / 0;
20+
});
1721
}
1822

1923
public void stop(boolean stopped) {

src/test/java/com/examplehub/basics/thread/TakeMoneyFromAccountExampleTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
package com.examplehub.basics.thread;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.junit.jupiter.api.Assertions.*;
64

5+
import org.junit.jupiter.api.Test;
6+
77
class TakeMoneyFromAccountExampleTest {
88
@Test
99
void test() throws InterruptedException {
1010
class Account implements Runnable {
1111
private int balance;
12-
public Account() {
13-
}
12+
13+
public Account() {}
14+
1415
public Account(int balance) {
1516
this.balance = balance;
1617
}
@@ -47,4 +48,4 @@ public void run() {
4748

4849
assertEquals(700, account.getBalance());
4950
}
50-
}
51+
}

src/test/java/com/examplehub/basics/thread/WaitNotifyExampleTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void test() throws InterruptedException {
7070
void testPrint1To10TwoThread() throws InterruptedException {
7171
class MyRunnable implements Runnable {
7272
private int count = 1;
73+
7374
@Override
7475
public void run() {
7576
while (true) {

0 commit comments

Comments
 (0)