import java.io.*; public class GPS { public TiniGPSReader term; public GPSDecoder decoder; private GPSStuff GPSData; public GPS(GPSStuff GPSData) { this.GPSData = GPSData; Queue GPSMessageQueue = new Queue(); try { term = new TiniGPSReader("serial0", 4800, GPSMessageQueue); decoder = new GPSDecoder(GPSMessageQueue,GPSData); term.start(); decoder.start(); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } public void stop() { if (decoder.isAlive()) { decoder.stopThread(); while (decoder.isAlive()) { } } if (term.isAlive()) { term.stopThread(); while (term.isAlive()) { } } } }