class ChopVegetablesTask implements Runnable { @Override public void run() { try { String[] vegetables = {"Tomato", "Lettuce", "Onion"}; for (String veggie : vegetables) { System.out.println("Chopping " + veggie); Thread.sleep((int) (Math.random() * 2500)); } System.out.println("All vegetables chopped!"); } catch (InterruptedException e) { System.err.println("Vegetable chopping was interrupted. Dinner is cancelled!"); System.exit(1); } } }