Skip to content

Commit

Permalink
Fixed indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Javinator9889 committed Nov 20, 2018
1 parent 61d1b7c commit 893c8f2
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions examples/4-CombiningThreadsAndPooling.md
Expand Up @@ -82,45 +82,45 @@ public class CombiningClass implements OnThreadCompletedListener {
mThreadsPooling.start();
}

@Override
public void onThreadCompletedListener(@NotNull Thread thread, @Nullable Throwable exception) {
// First, we will handle the exception
if (exception != null) {
System.err.println("Exception thrown by thread: " + thread.getName());
exception.printStackTrace();
}
// Handle finished threads
switch (thread.getName()) {
case FIRST_DIVIDE:
// First division thread has finished its execution
System.out.println("First division finished");
break;
case SECON_DIVIDE:
// Second divide thread has finished its execution
System.out.println("Second division finished");
break;
case HEAVY_OPERATIONS:
// Math calculations thread has finished its execution
// We can safely print the result
System.out.println("Heavy operations finished");
System.out.println("Operations result: " + mHeavyOperationResult.get());
break;
case PRIME_FACTORS:
// Prime factors thread has finished its execution
// We can safely print the result
System.out.println("Prime factors finished");
System.out.println("Prime factors:");
List<String> result = mPrimeFactorsResult.get();
// First element is a descriptor (in this case)
String firstItem = result.remove(0);
// Print prime factors
System.out.println(firstItem + " | Factors: " + Arrays.toString(result.toArray()));
break;
default:
System.err.println("Non contemplated case");
break;
}
@Override
public void onThreadCompletedListener(@NotNull Thread thread, @Nullable Throwable exception) {
// First, we will handle the exception
if (exception != null) {
System.err.println("Exception thrown by thread: " + thread.getName());
exception.printStackTrace();
}
// Handle finished threads
switch (thread.getName()) {
case FIRST_DIVIDE:
// First division thread has finished its execution
System.out.println("First division finished");
break;
case SECON_DIVIDE:
// Second divide thread has finished its execution
System.out.println("Second division finished");
break;
case HEAVY_OPERATIONS:
// Math calculations thread has finished its execution
// We can safely print the result
System.out.println("Heavy operations finished");
System.out.println("Operations result: " + mHeavyOperationResult.get());
break;
case PRIME_FACTORS:
// Prime factors thread has finished its execution
// We can safely print the result
System.out.println("Prime factors finished");
System.out.println("Prime factors:");
List<String> result = mPrimeFactorsResult.get();
// First element is a descriptor (in this case)
String firstItem = result.remove(0);
// Print prime factors
System.out.println(firstItem + " | Factors: " + Arrays.toString(result.toArray()));
break;
default:
System.err.println("Non contemplated case");
break;
}
}

// An example class that takes too much time to finish its working
public class HeavyLoadClass {
Expand Down

0 comments on commit 893c8f2

Please sign in to comment.