Give names to threads for debugging purposes.

This commit is contained in:
akwizgran
2012-11-26 14:48:10 +00:00
parent 721a6b8950
commit 98f1f26fcf
8 changed files with 16 additions and 10 deletions

View File

@@ -38,7 +38,7 @@ class AndroidExecutorImpl implements AndroidExecutor {
private void startIfNecessary() {
if(started.getAndSet(true)) return;
new Thread(loop).start();
new Thread(loop, "AndroidExecutor").start();
try {
startLatch.await();
} catch(InterruptedException e) {

View File

@@ -44,6 +44,7 @@ abstract class Connector extends Thread {
Connector(CryptoComponent crypto, ReaderFactory readerFactory,
WriterFactory writerFactory, ConnectorGroup group,
DuplexPlugin plugin, PseudoRandom random) {
super("Connector");
this.crypto = crypto;
this.readerFactory = readerFactory;
this.writerFactory = writerFactory;

View File

@@ -52,6 +52,7 @@ class ConnectorGroup extends Thread implements InvitationTask {
ReaderFactory readerFactory, WriterFactory writerFactory,
PluginManager pluginManager, int handle, int localInvitationCode,
int remoteInvitationCode) {
super("ConnectorGroup");
this.invitationManager = invitationManager;
this.crypto = crypto;
this.readerFactory = readerFactory;

View File

@@ -24,7 +24,7 @@ class ShutdownManagerImpl implements ShutdownManager {
}
protected Thread createThread(Runnable r) {
return new Thread(r);
return new Thread(r, "ShutdownManager");
}
public synchronized boolean removeShutdownHook(int handle) {

View File

@@ -90,6 +90,10 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
private class EventLoop extends Thread {
private EventLoop() {
super("EventLoop");
}
@Override
public void run() {
try {
@@ -140,7 +144,7 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
private final AtomicBoolean called = new AtomicBoolean(false);
private StartOnce(Runnable r) {
super(r);
super(r, "ShutdownManager");
}
@Override

View File

@@ -34,7 +34,7 @@ class PollerImpl implements Poller, Runnable {
public synchronized void start(Collection<Plugin> plugins) {
for(Plugin plugin : plugins) schedule(plugin);
new Thread(this).start();
new Thread(this, "Poller").start();
}
private synchronized void schedule(Plugin plugin) {

View File

@@ -66,13 +66,13 @@ class DuplexConnectionFactoryImpl implements DuplexConnectionFactory {
conn.write();
}
};
new Thread(write).start();
new Thread(write, "DuplexConnectionWriter").start();
Runnable read = new Runnable() {
public void run() {
conn.read();
}
};
new Thread(read).start();
new Thread(read, "DuplexConnectionReader").start();
}
public void createOutgoingConnection(ContactId c, TransportId t,
@@ -92,12 +92,12 @@ class DuplexConnectionFactoryImpl implements DuplexConnectionFactory {
conn.write();
}
};
new Thread(write).start();
new Thread(write, "DuplexConnectionWriter").start();
Runnable read = new Runnable() {
public void run() {
conn.read();
}
};
new Thread(read).start();
new Thread(read, "DuplexConnectionReader").start();
}
}

View File

@@ -66,7 +66,7 @@ class SimplexConnectionFactoryImpl implements SimplexConnectionFactory {
conn.read();
}
};
new Thread(read).start();
new Thread(read, "SimplexConnectionReader").start();
}
public void createOutgoingConnection(ContactId c, TransportId t,
@@ -84,6 +84,6 @@ class SimplexConnectionFactoryImpl implements SimplexConnectionFactory {
conn.write();
}
};
new Thread(write).start();
new Thread(write, "SimplexConnectionWriter").start();
}
}