private static Thread makeRunner( final Record record) { return new Thread(){ @Override public void run() { Scanner scanner = new Scanner(System.in); try { Runner.run(record); } catch (InsufficientFundsException ife) { System.out.println("Insufficient funds in your Mechanical Turk account. Would you like to:\n" + "[1] Add more money to your account and retry\n" + "[2] Quit\n"); int i; do { System.out.println("Type number corresponding to preference: "); i = scanner.nextInt(); if (i==2) System.exit(1); } while(i!=1); } catch (AccessKeyException aws) { System.out.println(String.format("There is a problem with your access keys: %s; Exiting...", aws.getMessage())); System.exit(0); } catch (IllegalAccessException | InterruptedException | IOException | InstantiationException | ClassNotFoundException e) { e.printStackTrace(); } finally { scanner.close(); } } }; }