线程同步

synchronized (line) {
	line.setStatus("停止");
	String gpstime = line.getGpstime() + "--"+ activity.line.get(j-1).getGpstime();
	line.setGpstime(gpstime);
	line.setTimer(time);
	getAddress(line);    //需要线程同步
	lineStop.add(line);
}

private void getAddress(final Line line) {
		GeoPoint point = line.getPoint2();
		final String path = "http://g.gpsoo.net/o.jsp?i="
				+ (point.getLongitudeE6()) / 1e6 + ","
				+ (point.getLatitudeE6()) / 1e6 + ",0";
		new Thread(new Runnable() {

			@Override
			public void run() {
				// TODO Auto-generated method stub
				String home = SystemUtil.getAddress(path);
				System.out.println(home);
				line.setAddress(home);
			}
		}).start();
	}
附上代码以自鉴!

你可能感兴趣的:(线程同步)