private void printGridletList(GridletList list, String name,
                            boolean detail, double gridletLatencyTime[])
    {
        int size = list.size();
        Gridlet gridlet = null;

        String indent = "    ";
        StringBuffer buffer = new StringBuffer(1000);
        buffer.append("\n\n============== OUTPUT for " + name + " ===========");
        buffer.append("\nGridlet ID" + indent + "STATUS" + indent +
                       "Resource ID" + indent + indent + "Cost" + indent +
                       indent + "CPU Time" + indent + indent + "Latency");

        // a loop to print the overall result
        int i = 0;
        boolean header = true;

        for (i = 0; i < size; i++)
        {
            gridlet = (Gridlet) list.get(i);

            buffer.append("\n");
            buffer.append(indent + gridlet.getGridletID() + indent + indent);
            buffer.append( gridlet.getGridletStatusString() );
            buffer.append(indent + indent + gridlet.getResourceID() +
                          indent + gridlet.getProcessingCost() +
                          indent + gridlet.getActualCPUTime() +
                          indent + gridletLatencyTime[gridlet.getGridletID()]);

            if (i != 0) {
                header = false;
            }

            writeFin(name, gridlet.getGridletID(),
                     GridSim.getEntityName(gridlet.getResourceID()),
                     gridlet.getProcessingCost(), gridlet.getActualCPUTime(),
                     GridSim.clock(), header);
        }

        if (detail == true)
        {
            // a loop to print each Gridlet's history
            for (i = 0; i < size; i++)
            {
                gridlet = (Gridlet) list.get(i);

                buffer.append( gridlet.getGridletHistory() );
                buffer.append("Gridlet #" + gridlet.getGridletID());
                buffer.append(", length = " + gridlet.getGridletLength()
                               + ", finished so far = " +
                               gridlet.getGridletFinishedSoFar());
                buffer.append("===========================================");
            }
        }

        buffer.append("\n====================================================");
        System.out.println( buffer.toString() );

    }