forked from I2P_Developers/i2p.i2p
more static atomics
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
package net.i2p.router.networkdb.kademlia;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.data.RouterInfo;
|
||||
import net.i2p.data.i2np.DatabaseSearchReplyMessage;
|
||||
@ -17,7 +19,7 @@ import net.i2p.util.Log;
|
||||
class SearchMessageSelector implements MessageSelector {
|
||||
private final Log _log;
|
||||
private final RouterContext _context;
|
||||
private static int __searchSelectorId = 0;
|
||||
private static final AtomicInteger __searchSelectorId = new AtomicInteger();
|
||||
private final Hash _peer;
|
||||
private boolean _found;
|
||||
private final int _id;
|
||||
@ -31,7 +33,7 @@ class SearchMessageSelector implements MessageSelector {
|
||||
_found = false;
|
||||
_exp = expiration;
|
||||
_state = state;
|
||||
_id = ++__searchSelectorId;
|
||||
_id = __searchSelectorId.incrementAndGet();
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("[" + _id + "] Created: " + toString());
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.DataHelper;
|
||||
@ -902,7 +903,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
|
||||
return "?";
|
||||
}
|
||||
|
||||
private static int __id = 0;
|
||||
private static final AtomicInteger __id = new AtomicInteger();
|
||||
|
||||
/**
|
||||
* postControlAction() can take many seconds, especially if it's failing,
|
||||
@ -925,7 +926,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Starting thread to forward " + portsToForwardNow.size() + " ports");
|
||||
Thread t = new Thread(new RegisterPortsThread(portsToForwardNow));
|
||||
t.setName("UPnP Port Opener " + (++__id));
|
||||
t.setName("UPnP Port Opener " + __id.incrementAndGet());
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
@ -967,7 +968,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Starting thread to un-forward " + portsToForwardNow.size() + " ports");
|
||||
Thread t = new Thread(new UnregisterPortsThread(portsToForwardNow));
|
||||
t.setName("UPnP Port Closer " + (++__id));
|
||||
t.setName("UPnP Port Closer " + __id.incrementAndGet());
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
|
Reference in New Issue
Block a user