public void body() {
    	logger.info(super.get_name() + " is starting...");

        // get the resource id
        if (resID < 0) {
        	logger.severe("Invalid resource: " + GridSim.getEntityName(resID));
            return;
        }
        
        boolean success = submitGridlets();
        
        if(success) {
        	logger.info(super.get_name() +  " is collecting jobs...");
        	
            Sim_event ev = new Sim_event();
        	while (Sim_system.running()) {
                super.sim_get_next(ev);

                // if the simulation finishes then exit the loop
                if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) {
                    break;
                }

                // process the received event
                processEvent(ev);
                
                // if all the Gridlets have been collected
                if (completedJobs.size() == numGenJobs) {
                    break;
                }
            }
        }
        else {
        	logger.severe(super.get_name() + " was unable to submit the jobs.");
        }

        // shut down all the entities, including GridStatistics entity since
        // we used it to record certain events.
        shutdownGridStatisticsEntity();
        shutdownUserEntity();
        terminateIOEntities();

        logger.info(super.get_name() + " is exiting...");
    }