我的一段代码
哇,居然可以插入一段代码
- //this my project
- /**
- * 2008 08 27
- */
- public void run()
- {
- try
- {
- long startTime = System.currentTimeMillis();
- long endTime = startTime;
- while (i_jugThread)
- {
- i_step++;
- startTime = System.currentTimeMillis();
- this.canvas.repaint();
- //this.canvas.serviceRepaints();
- if (this.state == STATE_LOADING)
- {
- if (!loadLock)
- {
- loadLock = true;
- Thread t = new Thread()
- {
- public void run()
- {
- // 加载耗时资源
- doLoadRes();
- //i_engine.canvas.freeBgImg();
- //state = STATE_BROWSE;
- }
- };
- t.start();
- }
- }
- else if (this.state == STATE_BROWSE)
- {
- }
- endTime = System.currentTimeMillis();
- if (endTime - startTime < INTERVAL)
- {
- // synchronized (this)
- // {
- // try
- // {
- // this.wait(INTERVAL - (endTime - startTime));
- // }
- // catch (Exception e)
- // {
- // if (MainMidlet.DEBUG)
- // e.printStackTrace();
- // }
- // }
- Thread.sleep(INTERVAL - (endTime - startTime));
- }
- if(i_waitJug)
- {
- synchronized (this) {
- try {
- this.wait(1000);
- } catch (Exception e) {}
- }
- }
- }
- }
- catch(Exception e)
- {
- if(MainMidlet.DEBUG)
- {
- System.out.println("engine run error.");
- e.printStackTrace();
- }
- }
- try
- {
- this.canvas.initEndImg();
- this.state = Engine.STATE_END;
- this.canvas.repaint();
- saveRMSData();
- midlet.destroyApp(false);
- midlet.notifyDestroyed();
- }
- catch (javax.microedition.midlet.MIDletStateChangeException e)
- {
- if (MainMidlet.DEBUG)
- e.printStackTrace();
- }
- }