Code example for ScheduledExecutorService

Methods: schedule, scheduleAtFixedRate

0
			System.out.println("Getting Readings");
			onResume(); 
			} 
		}; 
		 
		final ScheduledFuture beeperHandle = scheduler.scheduleAtFixedRate(beeper, 0, 10, SECONDS);
		//final ScheduledFuture beeperHandle = scheduler.schedule(beeper, 0, SECONDS); 
		scheduler.schedule(new Runnable() 
		{ 
			public void run() 
			 { 
			beeperHandle.cancel(true);
			System.out.println("Readings over");
			//scheduler.shutdown(); 
			//sm.unregisterListener(listen, accsensor); 
			//GetAccReadings(myFile, 5, 10, 10); 
			} 
		} 
		, 60 , SECONDS);
		 
	} 
 
	public void onResume() 
	{ 
		sm.registerListener(listen, accsensor, 1000000);
		flag=1;
	} 
	 
	 
	public void cnclBeepForAnHour()  
	{		 
		final Runnable beeper2 = new Runnable() 
		{ 
			public void run()  
			{ 
			System.out.println("cancelled");
			System.out.println("Sensor unregistered");
			onPause(); 
			} 
		}; 
		final ScheduledFuture beeperHandle2 = scheduler.scheduleAtFixedRate(beeper2, 5, 10, SECONDS);
		scheduler.schedule(new Runnable() 
		{ 
			public void run() 
			 { 
			beeperHandle2.cancel(true);
			System.out.println("Readings over");