/** * This method is called when the user asks to start the simulation in the context of the main UI * Thread. It creates the designated number of Palantiri and adds them to the PalantiriManager. It * then creates a Thread for each Being and has each Being attempt to acquire a Palantir for * gazing, mediated by the PalantiriManager. The BeingTheads call methods from the * MVP.RequiredViewOps interface to visualize what is happening to the user. */ @Override public void start() { // Initialize the PalantiriManager. getModel().makePalantiri(Options.instance().numberOfPalantiri()); // Initialize the count of the number of threads Beings use to // gaze. mGazingThreads = new AtomicLong(0); // Show the Beings on the UI. mView.get().showBeings(); // Show the palantiri on the UI. mView.get().showPalantiri(); // Create and start a BeingThread for each Being. beginBeingsThreads(Options.instance().numberOfBeings()); // Start a thread to wait for all the Being threads to finish // and then inform the View layer that the simulation is done. waitForBeingsThreads(); }