this.thePort = port; join1 = t1; join2 = t2;
try { join1.join(); join2.join(); // execution stops until both these thread finish } catch (InterruptedException e) { } try { thePort.close(); } catch (Exception e) { // the port's probably already been closed }