public void body()
    {
        LinkedList resList;

        // 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(2*SEC);    // wait for 2 seconds

            resList = getGridResourceList();
            if (resList.size() > 0) {
                break;
            }
            else {
                System.out.println(super.get_name() +
                        ": Waiting to get list of resources ...");
            }
        }

        // list of resource IDs that can support Advanced Reservation (AR)
        ArrayList resARList = new ArrayList();   
        
        // list of resource names that can support AR
        ArrayList resNameList = new ArrayList(); 
        
        int totalPE = 0;
        int i = 0;
        Integer intObj = null;   // resource ID
        String name;             // resource name

        // a loop that gets a list of resources that can support AR
        for (i = 0; i < resList.size(); i++)
        {
            intObj = (Integer) resList.get(i);

            // double check whether a resource supports AR or not.
            // In this example, all resources support AR.
            if (GridSim.resourceSupportAR(intObj) == true) 
            {
                // gets the name of a resource
                name = GridSim.getEntityName( intObj.intValue() );

                // gets the total number of PEs owned by a resource
                totalPE = super.getNumPE(intObj);

                // adds the resource ID, name and its total PE into 
                // their respective lists.
                resARList.add(intObj);
                resNameList.add(name);
            }
        }

        //----------------------------------------------------
        // sends one or more reservations to a gridresource entity
        sendReservation(resARList, resNameList);
        
        try
        {
            // then get the results or Gridlets back
            int size = list_.size() - failReservation_;
            for (i = 0; i < size; i++)
            {
                Gridlet gl = super.gridletReceive();
                this.receiveList_.add(gl);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }

        // shut down all the entities 
        shutdownGridStatisticsEntity();
        terminateIOEntities();
        shutdownUserEntity();
        System.out.println(super.get_name() + ":%%%% Exiting body() with " +
                "number of failed reservation is " + failReservation_);
    }