il metodo che contiene quel codice deve essere dichiarato con un throws
public void nome(...) throws InterruptedException