⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpumonitor.java

📁 First of all, the Applet-phone is a SIP User-Agent with audio and text messaging capabilities. But
💻 JAVA
字号:
/* * CPUMonitor.java * * Created on October 7, 2003, 8:02 AM */package gov.nist.security.bcs.monitor;/** * Class monitoring the CPU resources allocated for a service * @author  DERUELLE Jean */public class CPUMonitor {    /**Free Memory at the starting of the service*/        private long beforeInitMem=0;    /**Free Memory after an allocation in the service*/    private long afterInitMem=0;    /**Total allocated memory*/    private long allocatedMemory=0;      /**the access control context of the jvm with wich we will check the allocation permission*/    private java.security.AccessControlContext context=null;        /** Creates a new instance of CPUMonitor */    public CPUMonitor() {        SecurityManager securityManager=System.getSecurityManager();        if (securityManager != null)             context = (java.security.AccessControlContext) securityManager.getSecurityContext();                              //System.gc();        beforeInitMem = Runtime.getRuntime().freeMemory();                  }                /**     * Check the memory after an allocation     */    public void checkMemoryAfter(){        //System.gc();        afterInitMem = Runtime.getRuntime().freeMemory();                allocatedMemory=beforeInitMem-afterInitMem;                //System.out.println("AfterNew " + afterInitMem);        //System.out.println("memory Consumed " + allocatedMemory);                try{            gov.nist.security.permissions.AllocationPermission allocationPermission=                new gov.nist.security.permissions.AllocationPermission(                    Long.toString(allocatedMemory),"allocation");            //System.out.println("Checking in your group policy file for the following CPU RESOURCE PERMISSION : "+ allocationPermission);            context.checkPermission(allocationPermission);                     }        catch(Exception e){            System.out.println("Too much memory allocated : "+allocatedMemory);            System.out.println("The service is exited ");            System.exit(1);        }    }   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -