Utility.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.traceviewer.util;
00002 
00003 /**********************************************
00004  * 
00005  * Class to provide generic utility methods
00006  *
00007  **********************************************/
00008 public class Utility {
00009 
00010     /********
00011      * retrieve the maximum number of threads given the maximum threads, based
00012      *  on the number of available cores. 
00013      *  See {@link java.lang.Runtime.availableProcessors }
00014      * @param maxThreads : maximum number of threads that can be supported. 
00015      *         if the value is 0 then it will be ignored
00016      * @return
00017      */
00018     static public int getNumThreads(int maxThreads) {
00019 
00020         int available_cores  = Runtime.getRuntime().availableProcessors();
00021         
00022         if (maxThreads > 0)
00023             return Math.min(maxThreads, available_cores);
00024         else
00025             return available_cores;                 
00026     }
00027 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1