mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 21:42:07 +01:00
Use Async.go() in ReconnectionManager
This commit is contained in:
parent
8c8ac546a9
commit
8f8e0c7138
2 changed files with 21 additions and 6 deletions
|
@ -18,6 +18,7 @@ package org.jivesoftware.smack;
|
|||
|
||||
import org.jivesoftware.smack.XMPPException.StreamErrorException;
|
||||
import org.jivesoftware.smack.packet.StreamError;
|
||||
import org.jivesoftware.smack.util.Async;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Map;
|
||||
|
@ -250,10 +251,8 @@ public class ReconnectionManager {
|
|||
if (reconnectionThread != null && reconnectionThread.isAlive())
|
||||
return;
|
||||
|
||||
reconnectionThread = new Thread(reconnectionRunnable);
|
||||
reconnectionThread.setName("Smack Reconnection Manager (" + connection.getConnectionCounter() + ')');
|
||||
reconnectionThread.setDaemon(true);
|
||||
reconnectionThread.start();
|
||||
reconnectionThread = Async.go(reconnectionRunnable,
|
||||
"Smack Reconnection Manager (" + connection.getConnectionCounter() + ')');
|
||||
}
|
||||
|
||||
private final ConnectionListener connectionListener = new AbstractConnectionListener() {
|
||||
|
|
|
@ -18,15 +18,31 @@ package org.jivesoftware.smack.util;
|
|||
|
||||
public class Async {
|
||||
|
||||
public static void go(Runnable runnable) {
|
||||
/**
|
||||
* Creates a new thread with the given Runnable, marks it daemon, starts it and returns the started thread.
|
||||
*
|
||||
* @param runnable
|
||||
* @return the started thread.
|
||||
*/
|
||||
public static Thread go(Runnable runnable) {
|
||||
Thread thread = daemonThreadFrom(runnable);
|
||||
thread.start();
|
||||
return thread;
|
||||
}
|
||||
|
||||
public static void go(Runnable runnable, String threadName) {
|
||||
/**
|
||||
* Creates a new thread with the given Runnable, marks it daemon, sets the name, starts it and returns the started
|
||||
* thread.
|
||||
*
|
||||
* @param runnable
|
||||
* @param threadName the thread name.
|
||||
* @return the started thread.
|
||||
*/
|
||||
public static Thread go(Runnable runnable, String threadName) {
|
||||
Thread thread = daemonThreadFrom(runnable);
|
||||
thread.setName(threadName);
|
||||
thread.start();
|
||||
return thread;
|
||||
}
|
||||
|
||||
public static Thread daemonThreadFrom(Runnable runnable) {
|
||||
|
|
Loading…
Reference in a new issue