package com.k13n.lt_codes;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class Client {
  private final Decoder decoder;
  private ExecutorService executor;
  private Future<Boolean> lastJobFuture;

  public Client() {
    executor = Executors.newSingleThreadExecutor();
    decoder = new IncrementalDecoder(Server.DEFAULT_PACKET_SIZE);
  }

  public synchronized void stopProcessing() {
    try {
      lastJobFuture.get();
    } catch (InterruptedException | ExecutionException e) {
      e.printStackTrace();
    } finally {
      executor.shutdownNow();
    }
  }

  public void receive(final TransmissonPacket packet) {
    if (decoder.isDecodingFinished())
      return;

    lastJobFuture = executor.submit(new Callable<Boolean>() {
      @Override public Boolean call() throws Exception {
        return decoder.receive(packet);
      }
    });
  }

  public boolean transferSucceeded() {
    return decoder.isDecodingFinished();
  }

}

@@ -63,56 +63,8 @@
 le;%0A
-import java.util.concurrent.ExecutionException;%0A
 impo
@@ -171,22 +171,24 @@
 current.
-Future
+TimeUnit
 ;%0A%0Apubli
@@ -276,49 +276,8 @@
 tor;
-%0A  private Future%3CBoolean%3E lastJobFuture;
 %0A%0A  
@@ -483,26 +483,93 @@
     
-lastJobFuture.get(
+executor.shutdown();%0A      executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS
 );%0A 
@@ -605,29 +605,8 @@
 ion 
-%7C ExecutionException 
 e) %7B
@@ -637,54 +637,8 @@
 ();%0A
-    %7D finally %7B%0A      executor.shutdownNow();%0A
     
@@ -760,24 +760,8 @@
 %0A   
- lastJobFuture =
  exe

Simplify the Client class further