當前位置: 首頁>>代碼示例>>Java>>正文


Java System.currentTimeMillis方法代碼示例

本文整理匯總了Java中java.lang.System.currentTimeMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java System.currentTimeMillis方法的具體用法?Java System.currentTimeMillis怎麽用?Java System.currentTimeMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.System的用法示例。


在下文中一共展示了System.currentTimeMillis方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readyToConnect

import java.lang.System; //導入方法依賴的package包/類
/**
 * Check whether we can connect, according to our policies.
 * Currently, checks that we've waited TIME_BETWEEN_EXCHANGES_MILLIS 
 * milliseconds since the last exchange and that we're not already connecting.
 *
 * @return Whether or not we're ready to connect to a peer.
 * @see TIME_BETWEEN_EXCHANGES_MILLIS
 * @see getConnecting
 */
private boolean readyToConnect() {
  long now = System.currentTimeMillis();
  long lastExchangeMillis = mStore.getLong(LAST_EXCHANGE_TIME_KEY, -1);

  boolean timeSinceLastOK;
  if (lastExchangeMillis == -1) {
    timeSinceLastOK = true;
  } else if (now - lastExchangeMillis < TIME_BETWEEN_EXCHANGES_MILLIS) {
    timeSinceLastOK = false;
  } else {
    timeSinceLastOK = true;
  }
  Log.v(TAG, "Ready to connect? " + (timeSinceLastOK && !getConnecting()));
  Log.v(TAG, "Connecting: " + getConnecting());
  Log.v(TAG, "timeSinceLastOK: " + timeSinceLastOK);
  return timeSinceLastOK && !getConnecting(); 
}
 
開發者ID:casific,項目名稱:murmur,代碼行數:27,代碼來源:RangzenService.java

示例2: success

import java.lang.System; //導入方法依賴的package包/類
@Override
public void success(Exchange exchange) {
  // Latency of communication: Stop timer here.
  long exchangeStopTimeMillis = System.currentTimeMillis();
  // Latency of communication: Calculate RTT from # of round trips in exchange.
  // In this case, we're using a NonceEchoExchange, which includes one round-trip,
  // so the RTT time is just the time between the start and end of the exchange.
  long rttMillis = exchangeStopTimeMillis - exchangeStartTimeMillis;

  // Latency of communication: Record RTT and any other parameters.
  // TODO(lerner): Record time.
  String init = exchange.asInitiator ? "initiator" : "listener";
  Log.i(TAG, String.format("Exchange complete as %s, took %d milliseconds", init, rttMillis));

  BluetoothSocket activeSocket = (mSocket != null) ? mSocket : mBluetoothSpeaker.mSocket;
  RangzenService.this.logEventToCSV(new String[] {
    activeSocket.getRemoteDevice().getAddress(),
    init,
    Long.toString(System.currentTimeMillis()),
    Long.toString(rttMillis)
  });

  RangzenService.this.cleanupAfterExchange();
}
 
開發者ID:casific,項目名稱:murmur,代碼行數:25,代碼來源:RangzenService.java

示例3: readyToConnect

import java.lang.System; //導入方法依賴的package包/類
/**
 * Check whether we can connect, according to our policies.
 * Currently, checks that we've waited TIME_BETWEEN_EXCHANGES_MILLIS 
 * milliseconds since the last exchange and that we're not already connecting.
 *
 * @return Whether or not we're ready to connect to a peer.
 */
private boolean readyToConnect() {
  long now = System.currentTimeMillis();
  long lastExchangeMillis = mStore.getLong(LAST_EXCHANGE_TIME_KEY, -1);

    boolean timeSinceLastOK;
  if (lastExchangeMillis == -1) {
    timeSinceLastOK = true;
  } else if (now - lastExchangeMillis < TIME_BETWEEN_EXCHANGES_MILLIS) {
    timeSinceLastOK = false;
  } else {
    timeSinceLastOK = true;
  }
    if(!USE_MINIMAL_LOGGING) {
        log.info( "Ready to connect? " + (timeSinceLastOK && (getConnecting() == null)));
        log.info( "Connecting: " + getConnecting());
        log.info( "timeSinceLastOK: " + timeSinceLastOK);
    }
  return timeSinceLastOK && (getConnecting() == null);
}
 
開發者ID:casific,項目名稱:murmur,代碼行數:27,代碼來源:MurmurService.java

示例4: failure

import java.lang.System; //導入方法依賴的package包/類
@Override
public void failure(Exchange exchange, String reason) {
  long exchangeStopTimeMillis = System.currentTimeMillis();
  long rttMillis = exchangeStopTimeMillis - exchangeStartTimeMillis;
  Log.e(TAG, String.format("Exchange failed, latency benchmark took %d milliseconds", rttMillis));

  RangzenService.this.cleanupAfterExchange();
}
 
開發者ID:casific,項目名稱:murmur,代碼行數:9,代碼來源:RangzenService.java

示例5: initSearchLimitTimeout

import java.lang.System; //導入方法依賴的package包/類
public ArrayList initSearchLimitTimeout(int limit, long duration) {
    clearSolutions();
    this.limit = limit;
    this.timeout = duration+System.currentTimeMillis();
    this.searchLimitTimeout();
    return listSolutions;
}
 
開發者ID:Engelberg,項目名稱:tarantella,代碼行數:8,代碼來源:DancingLinkRoot.java

示例6: searchLimitTimeout

import java.lang.System; //導入方法依賴的package包/類
boolean searchLimitTimeout() {
	if (System.currentTimeMillis()>timeout) {
        timeoutFlag = true;
        return false;
    }
    if (this == this.r) {
        addSolution();
        if (limit == listSolutions.size()) {
            limitFlag = true;
            return false;
        }
        else 
        	return true;
    }
    else {
        DancingLink colHeader = this.chooseColumn();
        colHeader.cover();
        for (DancingLink i = colHeader.d; i!=colHeader; i=i.d) {
            for (DancingLink j = i.r; j !=i; j=j.r) {
                j.c.cover();
            }
            sol.add(i);
            if (! this.searchLimitTimeout())
            	return false;                			
            sol.remove(sol.size()-1);
           	for (DancingLink j = i.l; j!=i; j=j.l) {
           		j.c.uncover();
           	}             
        }
        if (colHeader.optional) {
            if (! this.searchLimitTimeout()) {
            	return false;
            }
        }
        colHeader.uncover();
        return true;
    }
}
 
開發者ID:Engelberg,項目名稱:tarantella,代碼行數:39,代碼來源:DancingLinkRoot.java

示例7: setLastExchangeTime

import java.lang.System; //導入方法依賴的package包/類
/**
 * Set the time of the last exchange, kept in storage, to the current time.
 */
private void setLastExchangeTime() {
  Log.i(TAG, "Setting last exchange time");
  long now = System.currentTimeMillis();
  mStore.putLong(LAST_EXCHANGE_TIME_KEY, now);
}
 
開發者ID:casific,項目名稱:murmur,代碼行數:9,代碼來源:RangzenService.java

示例8: setLastExchangeTime

import java.lang.System; //導入方法依賴的package包/類
/**
 * Set the time of the last exchange, kept in storage, to the current time.
 */
private void setLastExchangeTime() {
    if(!USE_MINIMAL_LOGGING) log.info( "Setting last exchange time");
  long now = System.currentTimeMillis();
  mStore.putLong(LAST_EXCHANGE_TIME_KEY, now);
}
 
開發者ID:casific,項目名稱:murmur,代碼行數:9,代碼來源:MurmurService.java


注:本文中的java.lang.System.currentTimeMillis方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。