コード例 #1
0
 public void run() {
   long nextStart = System.currentTimeMillis();
   try {
     while (!dead) {
       long timeToSleep = nextStart - System.currentTimeMillis();
       if (timeToSleep > 10) Thread.sleep(timeToSleep);
       nextStart += Tickable.TIME_TICK;
       if ((CMProps.Bools.MUDSTARTED.property()) && (!CMLib.threads().isAllSuspended())) {
         globalTickCount++;
         for (Iterator<Exit> iter = exits.iterator(); iter.hasNext(); ) {
           Exit exit = iter.next();
           try {
             if (!exit.tick(globalTickCount)) exits.remove(exit);
           } catch (Exception e) {
             Log.errOut("ServiceEngine", e.toString());
           }
         }
         for (Iterator<TimeClock> iter = clocks.iterator(); iter.hasNext(); ) {
           TimeClock clock = iter.next();
           try {
             if (!clock.tick(globalTickCount)) clocks.remove(clock);
           } catch (Exception e) {
             Log.errOut("ServiceEngine", e.toString());
           }
         }
       }
     }
   } catch (InterruptedException e) {
   }
 }
コード例 #2
0
ファイル: SynchronizedQueue.java プロジェクト: kykong/POSA-14
        public void run() {
          for (int i = 0; i < mMaxIterations; i++)
            try {
              if (Thread.interrupted()) {
                throw new InterruptedException();
              }
              Integer result = (Integer) mQueue.take();

              System.out.println("iteration = " + result);
            } catch (InterruptedException e) {
              System.out.println(
                  "Thread properly interrupted by " + e.toString() + " in consumerRunnable");
              // This isn't an error - it just means that
              // we've been interrupted by the main Thread.
              return;
            } catch (TimeoutException e) {
              System.out.println("Exception " + e.toString() + " occurred in consumerRunnable");
              // Indicate a timeout.
              mConsumerCounter = TIMEOUT_OCCURRED;
              return;
            } catch (Exception e) {
              System.out.println("Exception " + e.toString() + " occurred in consumerRunnable");
              // Indicate a failure.
              mConsumerCounter = FAILURE_OCCURRED;
              return;
            }
        }
コード例 #3
0
ファイル: Settings.java プロジェクト: Bettogc/frenzyApp
 /**
  * Acquire the current attribution id from the facebook app.
  *
  * @return returns null if the facebook app is not present on the phone.
  */
 public static String getAttributionId(ContentResolver contentResolver) {
   Cursor c = null;
   try {
     String[] projection = {ATTRIBUTION_ID_COLUMN_NAME};
     c = contentResolver.query(ATTRIBUTION_ID_CONTENT_URI, projection, null, null, null);
     if (c == null || !c.moveToFirst()) {
       return null;
     }
     String attributionId = c.getString(c.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME));
     return attributionId;
   } catch (Exception e) {
     Log.d(TAG, "Caught unexpected exception in getAttributionId(): " + e.toString());
     return null;
   } finally {
     if (c != null) {
       c.close();
     }
   }
 }
コード例 #4
0
ファイル: ClientMediator.java プロジェクト: zTrix/TankMania
 public void toberun() {
   if (_writer == null || _reader == null) {
     Logger.error("@ClientMediator.toberun: _writer or _reader null");
     return;
   }
   String s;
   while (true) {
     s = null;
     try {
       s = _reader.readLine();
     } catch (Exception e) {
       Logger.error("@ClientMediator.toberun: _read error, excep is " + e.toString());
       break;
     }
     if (s != null && s.length() > 0) {
       handleResquest(new String(s));
     }
   }
   Arena.addReq(_id, Const.LOSE_CONNECTION, null);
 }