public synchronized void gridletSubmit(Gridlet gridlet, boolean ack) {
    	int reqPE = gridlet.getNumPE();
    	
    	try {
	    	// reject the Gridlet if it requires more PEs than the maximum
	    	if(reqPE > super.totalPE_) {
	    		String userName = GridSim.getEntityName( gridlet.getUserID() );
	    		logger.warning("Gridlet #" + gridlet.getGridletID() + " from " +
    	                userName + " user requires " + gridlet.getNumPE() + " PEs." +
	    	            "\n--> The resource has only " + super.totalPE_ + " PEs.");
	    		gridlet.setGridletStatus(Gridlet.FAILED);
	    		super.sendFinishGridlet(gridlet);
	    		return;
	    	}
    	} catch(Exception ex) {
    		logger.log(Level.WARNING, "Exception on submission of a Gridlet", ex);
    	}
    	
    	// Creates a server side job
    	SSGridlet sgl = new SSGridlet(gridlet);  
    	
    	//-------------- FOR DEBUGGING PURPOSES ONLY  --------------
    	visualizer.notifyListeners(super.get_id(), ActionType.ITEM_ARRIVED, true, sgl);
        //----------------------------------------------------------
    	
        // if job cannot be scheduled immediately, then enqueue it
        if(!startGridlet(sgl)) {
        	enqueueGridlet(sgl);
            waitingJobs.add(sgl);
        }
        
        if (ack) {
            // sends back an ack
        	super.sendAck(GridSimTags.GRIDLET_SUBMIT_ACK, true,
        			gridlet.getGridletID(), gridlet.getUserID());
        }
        
    	//------------------ FOR DEBUGGING PURPOSES ONLY ----------------
        visualizer.notifyListeners(super.get_id(), ActionType.ITEM_SCHEDULED, true, sgl);
    	//---------------------------------------------------------------
    }