1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-23 04:57:58 +01:00

Added unique identifier to each thread name (SMACK-51).

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@6948 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2007-02-04 20:52:45 +00:00 committed by matt
parent 2407d9e30f
commit bf02dbe3da
3 changed files with 10 additions and 4 deletions

View file

@ -77,7 +77,7 @@ class PacketReader {
parsePackets(this);
}
};
readerThread.setName("Smack Packet Reader");
readerThread.setName("Smack Packet Reader (" + connection.connectionCounterValue + ")");
readerThread.setDaemon(true);
listenerThread = new Thread() {
@ -90,7 +90,7 @@ class PacketReader {
}
}
};
listenerThread.setName("Smack Listener Processor");
listenerThread.setName("Smack Listener Processor (" + connection.connectionCounterValue + ")");
listenerThread.setDaemon(true);
resetParser();

View file

@ -92,7 +92,7 @@ class PacketWriter {
writePackets(this);
}
};
writerThread.setName("Smack Packet Writer");
writerThread.setName("Smack Packet Writer (" + connection.connectionCounterValue + ")");
writerThread.setDaemon(true);
}
@ -222,7 +222,7 @@ class PacketWriter {
keepAliveThread = new Thread(target);
target.setThread(keepAliveThread);
keepAliveThread.setDaemon(true);
keepAliveThread.setName("Smack Keep Alive");
keepAliveThread.setName("Smack Keep Alive (" + connection.connectionCounterValue + ")");
keepAliveThread.start();
}
}

View file

@ -37,6 +37,7 @@ import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Creates a connection to a XMPP server. A simple use of this API might
@ -91,6 +92,10 @@ public class XMPPConnection {
private final static Set<ConnectionCreationListener> connectionEstablishedListeners =
new CopyOnWriteArraySet<ConnectionCreationListener>();
// Counter to uniquely identify connections that are created. This is distinct from the
// connection ID, which is a value sent by the server once a connection is made.
private static AtomicInteger connectionCounter = new AtomicInteger(0);
static {
// Use try block since we may not have permission to get a system
// property (for example, when an applet).
@ -121,6 +126,7 @@ public class XMPPConnection {
*/
String serviceName;
int connectionCounterValue = connectionCounter.getAndIncrement();
String connectionID = null;
private String user = null;
private boolean connected = false;