[BAEL-7073] fix code style
This commit is contained in:
parent
1c5e81fa34
commit
596c10de0a
|
@ -4,12 +4,10 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
|
||||
public class ExecuteExample {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(2);
|
||||
// Task using Runnable
|
||||
Runnable task = () ->
|
||||
{
|
||||
Runnable task = () -> {
|
||||
int[] numbers = { 1, 2, 3, 4, 5 };
|
||||
int sum = 0;
|
||||
for (int num : numbers) {
|
||||
|
@ -18,7 +16,8 @@ public class ExecuteExample {
|
|||
System.out.println("Sum calculated using execute:" + sum);
|
||||
};
|
||||
// Submit the task using execute
|
||||
executorService.execute(task); executorService.shutdown();
|
||||
executorService.execute(task);
|
||||
executorService.shutdown();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,9 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.Future;
|
||||
|
||||
public class SubmitExample {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(2);
|
||||
Callable<Integer> task = () ->
|
||||
{
|
||||
Callable<Integer> task = () -> {
|
||||
int[] numbers = { 1, 2, 3, 4, 5 };
|
||||
int sum = 0;
|
||||
for (int num : numbers) {
|
||||
|
@ -25,8 +23,7 @@ public class SubmitExample {
|
|||
// Get the result
|
||||
int sum = result.get();
|
||||
System.out.println("Sum calculated using submit:" + sum);
|
||||
} catch (InterruptedException | ExecutionException e)
|
||||
{
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
executorService.shutdown();
|
||||
|
|
Loading…
Reference in New Issue