コード例 #1
0
 public void serve(Socket s) {
   try {
     doService(s);
     synchronized (this) {
       notify();
     }
     s.close();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
コード例 #2
0
 public synchronized void publish(LogRecord record) {
   if (!record.getMessage().startsWith("cnt")) {
     return;
   }
   boolean snd = Thread.currentThread().getName().equals("2nd");
   if (runSecond == snd) {
     notify();
     runSecond = !runSecond;
   }
   try {
     wait(500);
   } catch (InterruptedException ex) {
   }
 }
コード例 #3
0
ファイル: ContendedLockTest.java プロジェクト: truward/Tupl
    public void run() {
      try {
        Transaction txn = mDb.newTransaction();

        if (mNoGhost) {
          mIx.lockExclusive(txn, mKey);
          mIx.store(Transaction.BOGUS, mKey, mValue);
        } else {
          mIx.store(txn, mKey, mValue);
        }

        synchronized (this) {
          mSleeping = true;
          notify();
        }
        Thread.sleep(500);
        txn.commit();
      } catch (Exception e) {
      }
    }