Skip to content

Commit 4d8f92e

Browse files
author
eugenp
committed
formatting cleanup
1 parent f913859 commit 4d8f92e

20 files changed

Lines changed: 96 additions & 124 deletions

File tree

core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierDemo.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ public class CyclicBarrierDemo {
1515
private int NUM_PARTIAL_RESULTS;
1616
private int NUM_WORKERS;
1717

18-
1918
private void runSimulation(int numWorkers, int numberOfPartialResults) {
2019
NUM_PARTIAL_RESULTS = numberOfPartialResults;
2120
NUM_WORKERS = numWorkers;
2221

2322
cyclicBarrier = new CyclicBarrier(NUM_WORKERS, new AggregatorThread());
24-
System.out.println("Spawning " + NUM_WORKERS + " worker threads to compute "
25-
+ NUM_PARTIAL_RESULTS + " partial results each");
23+
System.out.println("Spawning " + NUM_WORKERS + " worker threads to compute " + NUM_PARTIAL_RESULTS + " partial results each");
2624
for (int i = 0; i < NUM_WORKERS; i++) {
2725
Thread worker = new Thread(new NumberCruncherThread());
2826
worker.setName("Thread " + i);
@@ -38,8 +36,7 @@ public void run() {
3836
List<Integer> partialResult = new ArrayList<>();
3937
for (int i = 0; i < NUM_PARTIAL_RESULTS; i++) {
4038
Integer num = random.nextInt(10);
41-
System.out.println(thisThreadName
42-
+ ": Crunching some numbers! Final result - " + num);
39+
System.out.println(thisThreadName + ": Crunching some numbers! Final result - " + num);
4340
partialResult.add(num);
4441
}
4542
partialResults.add(partialResult);
@@ -57,13 +54,12 @@ class AggregatorThread implements Runnable {
5754
@Override
5855
public void run() {
5956
String thisThreadName = Thread.currentThread().getName();
60-
System.out.println(thisThreadName + ": Computing final sum of " + NUM_WORKERS
61-
+ " workers, having " + NUM_PARTIAL_RESULTS + " results each.");
57+
System.out.println(thisThreadName + ": Computing final sum of " + NUM_WORKERS + " workers, having " + NUM_PARTIAL_RESULTS + " results each.");
6258
int sum = 0;
6359
for (List<Integer> threadResult : partialResults) {
6460
System.out.print("Adding ");
6561
for (Integer partialResult : threadResult) {
66-
System.out.print(partialResult+" ");
62+
System.out.print(partialResult + " ");
6763
sum += partialResult;
6864
}
6965
System.out.println();

core-java/src/main/java/com/baeldung/concurrent/diningphilosophers/Philosopher.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ private void doAction(String action) throws InterruptedException {
1515
Thread.sleep(((int) (Math.random() * 100)));
1616
}
1717

18-
@Override public void run() {
18+
@Override
19+
public void run() {
1920
try {
2021
while (true) {
2122
doAction(System.nanoTime() + ": Thinking"); // thinking

core-java/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66

77
public class ExecutorServiceDemo {
88

9-
ExecutorService executor = Executors.newFixedThreadPool(10);
9+
ExecutorService executor = Executors.newFixedThreadPool(10);
1010

11-
public void execute() {
11+
public void execute() {
1212

13-
executor.submit(() -> {
14-
new Task();
15-
});
13+
executor.submit(() -> {
14+
new Task();
15+
});
1616

17-
executor.shutdown();
18-
executor.shutdownNow();
19-
try {
20-
executor.awaitTermination(20l, TimeUnit.NANOSECONDS);
21-
} catch (InterruptedException e) {
22-
e.printStackTrace();
23-
}
17+
executor.shutdown();
18+
executor.shutdownNow();
19+
try {
20+
executor.awaitTermination(20l, TimeUnit.NANOSECONDS);
21+
} catch (InterruptedException e) {
22+
e.printStackTrace();
23+
}
2424

25-
}
25+
}
2626

2727
}

core-java/src/main/java/com/baeldung/concurrent/future/FutureDemo.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,36 @@
99

1010
public class FutureDemo {
1111

12-
public String invoke() {
12+
public String invoke() {
1313

14-
String str = null;
14+
String str = null;
1515

16-
ExecutorService executorService = Executors.newFixedThreadPool(10);
16+
ExecutorService executorService = Executors.newFixedThreadPool(10);
1717

18-
Future<String> future = executorService.submit(() -> {
19-
// Task
20-
Thread.sleep(10000l);
21-
return "Hellow world";
22-
});
18+
Future<String> future = executorService.submit(() -> {
19+
// Task
20+
Thread.sleep(10000l);
21+
return "Hellow world";
22+
});
2323

24-
future.cancel(false);
24+
future.cancel(false);
2525

26-
try {
27-
future.get(20, TimeUnit.SECONDS);
28-
} catch (InterruptedException | ExecutionException | TimeoutException e1) {
29-
e1.printStackTrace();
30-
}
26+
try {
27+
future.get(20, TimeUnit.SECONDS);
28+
} catch (InterruptedException | ExecutionException | TimeoutException e1) {
29+
e1.printStackTrace();
30+
}
3131

32-
if (future.isDone() && !future.isCancelled()) {
33-
try {
34-
str = future.get();
35-
} catch (InterruptedException | ExecutionException e) {
36-
e.printStackTrace();
37-
}
38-
}
32+
if (future.isDone() && !future.isCancelled()) {
33+
try {
34+
str = future.get();
35+
} catch (InterruptedException | ExecutionException e) {
36+
e.printStackTrace();
37+
}
38+
}
3939

40-
return str;
40+
return str;
4141

42-
}
42+
}
4343

4444
}

core-java/src/main/java/com/baeldung/concurrent/threadfactory/BaeldungThreadFactory.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44

55
public class BaeldungThreadFactory implements ThreadFactory {
66

7-
private int threadId;
8-
private String name;
7+
private int threadId;
8+
private String name;
99

10-
public BaeldungThreadFactory(String name) {
11-
threadId = 1;
12-
this.name = name;
13-
}
10+
public BaeldungThreadFactory(String name) {
11+
threadId = 1;
12+
this.name = name;
13+
}
1414

15-
@Override
16-
public Thread newThread(Runnable r) {
17-
Thread t = new Thread(r, name + "-Thread_" + threadId);
18-
System.out.println("created new thread with id : " + threadId + " and name : " + t.getName());
19-
threadId++;
20-
return t;
21-
}
15+
@Override
16+
public Thread newThread(Runnable r) {
17+
Thread t = new Thread(r, name + "-Thread_" + threadId);
18+
System.out.println("created new thread with id : " + threadId + " and name : " + t.getName());
19+
threadId++;
20+
return t;
21+
}
2222

2323
}

core-java/src/main/java/com/baeldung/concurrent/threadfactory/Task.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
public class Task implements Runnable {
44

5-
@Override
6-
public void run() {
7-
// task details
8-
}
9-
5+
@Override
6+
public void run() {
7+
// task details
8+
}
9+
1010
}

core-java/src/main/java/com/baeldung/filesystem/jndi/LookupFSJNDI.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,25 @@ public LookupFSJNDI() throws NamingException {
1414
super();
1515
init();
1616
}
17-
17+
1818
private void init() throws NamingException {
1919
Hashtable<String, String> env = new Hashtable<String, String>();
20-
21-
env.put (Context.INITIAL_CONTEXT_FACTORY,
22-
"com.sun.jndi.fscontext.RefFSContextFactory");
20+
21+
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
2322
// URI to namespace (actual directory)
2423
env.put(Context.PROVIDER_URL, "file:./src/test/resources");
25-
24+
2625
ctx = new InitialContext(env);
2726
}
2827

2928
public InitialContext getCtx() {
3029
return ctx;
3130
}
32-
31+
3332
public File getFile(String fileName) {
3433
File file;
3534
try {
36-
file = (File)getCtx().lookup(fileName);
35+
file = (File) getCtx().lookup(fileName);
3736
} catch (NamingException e) {
3837
file = null;
3938
}

core-java/src/main/java/com/baeldung/hashcode/entities/User.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ public User(long id, String name, String email) {
1818

1919
@Override
2020
public boolean equals(Object o) {
21-
if (this == o) return true;
22-
if (o == null) return false;
23-
if (this.getClass() != o.getClass()) return false;
21+
if (this == o)
22+
return true;
23+
if (o == null)
24+
return false;
25+
if (this.getClass() != o.getClass())
26+
return false;
2427
User user = (User) o;
2528
return id != user.id && (!name.equals(user.name) && !email.equals(user.email));
2629
}
27-
30+
2831
@Override
2932
public int hashCode() {
3033
int hash = 7;

core-java/src/main/java/com/baeldung/jmx/JMXTutorialMainlauncher.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public class JMXTutorialMainlauncher {
1010

1111
private static final Logger LOG = LoggerFactory.getLogger(JMXTutorialMainlauncher.class);
1212

13-
1413
public static void main(String[] args) {
1514
// TODO Auto-generated method stub
1615

core-java/src/main/java/com/baeldung/socket/EchoClient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88

99
public class EchoClient {
1010

11-
1211
private static final Logger LOG = LoggerFactory.getLogger(EchoClient.class);
13-
12+
1413
private Socket clientSocket;
1514
private PrintWriter out;
1615
private BufferedReader in;

0 commit comments

Comments
 (0)