private void processGridletSubmission(Sim_event ev)
    {
        if (trace_flag)
        {
            System.out.println(super.get_name() +
                ": received an SUBMIT_GRIDLET event. Clock: " + GridSim.clock());
        }

        /***********
        We have to submit:
             - the gridlet whose id comes with the event
             - all the gridlets with the "gridletSub.getSubmitted() == false"

        So, set the gridletSub.getSubmitted() to false for the gridlet whose
        id comes with the event
        ***********/

        int i = 0;
        GridletSubmission gridletSub;
        int resourceID[];
        Random random = new Random(5);   // a random generator with a random seed
        int index;
        Gridlet gl;
        Integer obj;
        int glID;

        // This is because the initial GRIDLET_SUBMIT event, at the beginning
        // of sims, does not have any gridlet id. We have to submit
        // all the gridlets.
        if (ev.get_data() instanceof Integer)
        {
            obj = (Integer) ev.get_data();
            glID = obj.intValue(); // get the gridlet id.
        }
        else {
            glID = 99; // a value at random, not used at all in this case
        }

        while (i < GridletSubmittedList_.size())
        {
            gridletSub = (GridletSubmission)GridletSubmittedList_.get(i);

            if ( (gridletSub.getGridlet()).getGridletID() == glID )
            {
                // set this gridlet whose id comes with the event as not submitted,
                // so that it is submitted as soon as possible.
                ((GridletSubmission) GridletSubmittedList_.get(i)).setSubmitted(false);
            }

            // Submit the gridlets with the "gridletSub.getSubmitted() == false"
            if ( (gridletSub.getSubmitted() == false))
            {
                // we have to resubmit this gridlet
                gl = ((GridletSubmission) GridletSubmittedList_.get(i)).getGridlet();
                resourceID = getResList(); // Get list of resources from GIS

                // If we have resources in the list
                if ((resourceID != null) && (resourceID.length != 0))
                {
                    index = random.nextInt(resourceID.length);

                    // make sure the gridlet will be executed from the begining
                    resetGridlet(gl);

                    // submits this gridlet to a resource
                    super.gridletSubmit(gl, resourceID[index]);
                    gridletSubmissionTime[gl.getGridletID()] = GridSim.clock();

                    // set this gridlet as submitted
                    ((GridletSubmission) GridletSubmittedList_.get(i)).setSubmitted(true);

                    if (trace_flag)
                    {
                        System.out.println(super.get_name() +
                               ": Sending Gridlet #" + i + " to " +
                               GridSim.getEntityName(resourceID[index]) +
                               " at clock: " + GridSim.clock());

                        // Write into a results file
                        write(super.get_name(), "Sending", gl.getGridletID(),
                              GridSim.getEntityName(resourceID[index]),
                              gl.getGridletStatusString(), GridSim.clock());
                    }

                }
                // No resources available at this moment, so schedule an event
                // in the future. The event wil be in 15 min (900 sec), as
                // resource failures may last several hours.
                // This event includes the gridletID, so that the user will
                // try to submit only this gridlet
                else
                {
                    super.send(super.get_id(), GridSimTags.SCHEDULE_NOW + 900,
                               GridUserFailureEx03.SUBMIT_GRIDLET,
                               new Integer(gl.getGridletID()) );
                }

            }// if (gridletSub.getSubmitted() == false)

            i++;
        } // while (i < GridletSubmittedList_.size())

    } // processGridletSubmission