• 模拟帧频率。。。


    int runTime=1000*5;
            int FrameRate=1000/6;
            int checkTime=FrameRate;
            
            long startTime=new Date().getTime();
            while(runTime>checkTime)
            {
                //checkValue=moveVector3(90, checkValue);
                //checkValue.print();
                checkTime+=FrameRate;
                System.out.println(checkTime);
                try {
                    Thread.sleep(FrameRate);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            long endTime=new Date().getTime();
            System.out.println(endTime-startTime);

    修正延时

    public static void main(String[] args)
        {
            int runTime=1000;
            int FrameRate=1000/6;
            int checkTime=FrameRate;
            long startTime,entTime;
           
            long checkSTime=new Date().getTime();
            int i=0;
            while(runTime>checkTime)
            {
                System.out.println(i);
                startTime =new Date().getTime();
                try {
                    Thread.sleep(300);
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }
                entTime=new Date().getTime();
                
                long check=entTime-startTime;
                if(check<FrameRate)
                    checkTime+=FrameRate;
                else
                    checkTime+=check;
                i++;
                try {
                    if(check<FrameRate)
                        Thread.sleep(FrameRate-check);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("time : " +( new Date().getTime()-checkSTime));
            
        }
  • 相关阅读:
    C++ sort()函数的用法
    对C++里面 的知识积累:
    codevs 1160
    hdu 1020 Encoding
    poj 2591 Set Definition
    hdu 1505,1506
    hdu 1284 钱币兑换
    hdu 1231 最大连续子序列 ,1003 Max Sum;
    尺取法
    android OTA package packing and extract to partition
  • 原文地址:https://www.cnblogs.com/solq/p/2650720.html
Copyright © 2020-2023  润新知