share data between timer based Event (thread) and onLocationChange in android
===

Scenario-
I have a timer based Event thread where I am sending data (latitude and longitude) through post request. I have an onLocationChange method (my class implements on LocationListener) which is called on location change. It sets the new latitude and longitude value which should be called later by the timer Event.

The timer Event does not take the latest latitude and longitude values on location change event. When the timer event starts ,it does not call the onlocationchange method even when location is changed. 

Here's the timer event:

/** This method calls the service every 10 seconds. */


	protected void timerMethod(CookieStore cookieStore, String url) {
		int delay = 1000; // delay for 1 sec.
		int period = 10000; // repeat every 10 sec.
		timer = new Timer();
		if (timer != null) {
			timer.scheduleAtFixedRate(new TimerTask() {
				public void run() {
					timerThread = new Thread() {
						@Override
						public void run() {
							
							sendpostRequest();  // calling the post method
						}
					};
					timerThread.start();
					
				}
			}, delay, period);
		}
	}


Here's the location change event:

/** This method is Called when the location has changed. */

	public void onLocationChanged(Location location) {

		isLocationChanged = true;  // setting a boolean value which is checked while posting the request
		System.out.println();
		System.out.println("Location change:::longitude::::" + location.getLongitude() + "latiude::::"
				+ location.getLatitude());

		latClient = location.getLatitude();
		longClient = location.getLongitude();

	}