public void body()
    {
        int resourceID = 0;
        String resourceName;
        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 = super.getGridResourceList();
            if (resList.size() > 0)
            {
                // in this example, we know that we only create one resource.
                // Resource list contains list of resource IDs not grid
                // resource objects.
                Integer num = (Integer) resList.get(0);
                resourceID = num.intValue();

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

                // waiting to get a resource characteristics
                resChar = (ResourceCharacteristics) super.receiveEventObject();
                resourceName = resChar.getResourceName();

                System.out.println("Received ResourceCharacteristics from " +
                        resourceName + ", with id = " + resourceID);

                // record this event into "stat.txt" file
                super.recordStatistics("\"Received ResourceCharacteristics " +
                        "from " + resourceName + "\"", "");

                break;
            }
            else
                System.out.println("Waiting to get list of resources ...");
        }

        Gridlet gridlet;
        String info;

        // a loop to get one Gridlet at one time and sends it to a grid
        // resource entity. Then waits for a reply
        for (int i = 0; i < this.list_.size(); i++)
        {
            gridlet = (Gridlet) this.list_.get(i);
            info = "Gridlet_" + gridlet.getGridletID();

            System.out.println("Sending " + info + " to " + resourceName +
                    " with id = " + resourceID);

            // Sends one Gridlet to a grid resource specified in "resourceID"
            super.gridletSubmit(gridlet, resourceID);

            // OR another approach to send a gridlet to a grid resource entity
            //super.send(resourceID, GridSimTags.SCHEDULE_NOW,
            //      GridSimTags.GRIDLET_SUBMIT, gridlet);

            // Recods this event into "stat.txt" file for statistical purposes
            super.recordStatistics("\"Submit " + info + " to " + resourceName +
                    "\"", "");

            // waiting to receive a Gridlet back from resource entity
            gridlet = super.gridletReceive();
            System.out.println("Receiving Gridlet " + gridlet.getGridletID());

            // Recods this event into "GridSim_stat.txt" file for statistical
            // purposes
            super.recordStatistics("\"Received " + info +  " from " +
                    resourceName + "\"", gridlet.getProcessingCost());

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

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