Code example for TimeUnit

Methods: convert

0
	 * @param frequency The frequency in seconds of the memory reporting 
	 */ 
	public MemoryReporter(int frequency) {
		super("MemoryReporter-" + frequency);
		setDaemon(true);		
		sleepTime = TimeUnit.MILLISECONDS.convert(frequency, TimeUnit.SECONDS);
	} 
	 
	/** 
	 * Broadcasts the heap memory usage every <code>sleepTime</code> ms. 
	 * {@inheritDoc} 
	 * @see java.lang.Thread#run() 
	 */ 
	public void run() { 
		while(true) { 
			try { join(sleepTime); } catch (Exception e) {}
			MemoryUsage musage = mxBean.getHeapMemoryUsage();
			SharedChannelGroup.getInstance().write(new JSONObject(musage));
		} 
	} 
}