本文整理汇总了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();
}
示例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();
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
}
示例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);
}
示例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);
}