Package cz.cuni.mff.abacs.burglar.visual.multithreading

Source Code of cz.cuni.mff.abacs.burglar.visual.multithreading.LoadingThread

/**
*
*/
package cz.cuni.mff.abacs.burglar.visual.multithreading;

import cz.cuni.mff.abacs.burglar.logics.ExecutingMap;
import cz.cuni.mff.abacs.burglar.logics.storage.XMLLoader;


/**
* Thread executing level loading.
*
* Immutable class.
*
* Measures the executing time of the loading.
*
* @author abacs
*
*/
public class LoadingThread extends Thread {
 
 
  /** Address to return the results. */
  private LoadingListener _listener;
  /** Map file to load. */
  private final String _mapFile;
 
 
  // -------------------------------------------------------------------------
  // constructors:
 
 
  /**
   * 
   *
   * @param mapFileName
   * @param listener
   */
  public LoadingThread(String mapFileName, LoadingListener listener) {
    super();
    this._mapFile = mapFileName;
    this._listener = listener;
  }
 
 
  // -------------------------------------------------------------------------
 
 
  /* (non-Javadoc)
   * @see java.lang.Runnable#run()
   */
  @Override
  public void run() {
    long startTime = System.currentTimeMillis();
   
    ExecutingMap map = XMLLoader.load(this._mapFile);
    ExecutingMap secondaryMap = XMLLoader.load(this._mapFile);
   
    long endTime = System.currentTimeMillis();
   
    long duration = endTime - startTime;
   
    System.out.println("- Map loading time: " + duration + " ms.");
   
    this._listener.loadingFinished(map, secondaryMap);
  }
 
 
  // -------------------------------------------------------------------------

}
TOP

Related Classes of cz.cuni.mff.abacs.burglar.visual.multithreading.LoadingThread

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.