public void body()
    {
        int resourceID[] = new int[this.totalResource_];
        double resourceCost[] = new double[this.totalResource_];
        String resourceName[] = new String[this.totalResource_];

        LinkedList resList;
        ResourceCharacteristics resChar;

        // waiting to get list of resources. Since GridSim package uses
        // multi-threaded environment, your request might arrive earlier
        // before one or more grid resource entities manage to register
        // themselves to GridInformationService (GIS) entity.
        // Therefore, it's better to wait in the first place
        while (true)
        {
            // need to pause for a while to wait GridResources finish
            // registering to GIS
            super.gridSimHold(1.0);    // hold by 1 second

            resList = getGridResourceList();
            if (resList.size() == this.totalResource_)
                break;
            else
            {
                System.out.println(this.name_ +
                        ":Waiting to get list of resources ...");
            }
        }

        // a loop to get all the resources available
        int i = 0;
        for (i = 0; i < this.totalResource_; i++)
        {
            // Resource list contains list of resource IDs not grid resource
            // objects.
            resourceID[i] = ( (Integer)resList.get(i) ).intValue();

            // Requests to resource entity to send its characteristics
            send(resourceID[i], GridSimTags.SCHEDULE_NOW,
                    GridSimTags.RESOURCE_CHARACTERISTICS, this.ID_);

            // waiting to get a resource characteristics
            resChar = (ResourceCharacteristics) receiveEventObject();
            resourceName[i] = resChar.getResourceName();
            resourceCost[i] = resChar.getCostPerSec();

            System.out.println(this.name_ +
                    ":Received ResourceCharacteristics from " +
                    resourceName[i] + ", with id = " + resourceID[i]);
        }

        /////////////////////////////////////////////////////
        // SUBMITS Gridlets

        Gridlet gridlet = null;
        String info;

        // a loop to get one Gridlet at one time and sends it to a random grid
        // resource entity. Then waits for a reply
        int id = 0;
        boolean success = false;

        for (i = 0; i < this.list_.size(); i++)
        {
            gridlet = (Gridlet) this.list_.get(i);
            info = "Gridlet_" + gridlet.getGridletID();

            System.out.println(this.name_ + ":Sending " + info + " to " +
                    resourceName[id] + " with id = " + resourceID[id] +
                    " at time = " + GridSim.clock() );

            // Sends one Gridlet to a grid resource specified in "resourceID"
            // Gridlets with even numbers are sent and required an ack
            if (i % 2 == 0)
            {
                success = gridletSubmit(gridlet, resourceID[id], 0.0, true);
                System.out.println("Ack = " + success);
                System.out.println();
            }

            // Gridlets with odd numbers are sent but not required an ack
            else {
                success = gridletSubmit(gridlet, resourceID[id], 0.0, false);
            }
        }

        //////////////////////////////////////////////////
        // RECEIVES Gridlets

        super.gridSimHold(20);
        System.out.println("<<<<<< pauses for 20 seconds >>>>>>>>");

        // A loop to receive all the Gridlets back
        for (i = 0; i < this.list_.size(); i++)
        {
            // waiting to receive a Gridlet back from resource entity
            gridlet = (Gridlet) super.receiveEventObject();

            System.out.println(this.name_ + ":Receiving Gridlet " +
                    gridlet.getGridletID() );

            // stores the received Gridlet into a new GridletList object
            this.receiveList_.add(gridlet);
        }

        // shut down this simulation
        shutdownUserEntity();
        terminateIOEntities();
        System.out.println(this.name_ + ":%%%% Exiting body()");
    }