Replace a few runnables with lambdas.

This commit is contained in:
akwizgran
2017-12-01 13:47:54 +00:00
parent c8326103b4
commit 030b52261d
3 changed files with 46 additions and 61 deletions

View File

@@ -150,17 +150,14 @@ public class LanTcpPluginTest extends BrambleTestCase {
int port = ss.getLocalPort();
CountDownLatch latch = new CountDownLatch(1);
AtomicBoolean error = new AtomicBoolean(false);
new Thread() {
@Override
public void run() {
new Thread(() -> {
try {
ss.accept();
latch.countDown();
} catch (IOException e) {
error.set(true);
}
}
}.start();
}).start();
// Tell the plugin about the port
TransportProperties p = new TransportProperties();
p.put("ipPorts", addrString + ":" + port);
@@ -243,17 +240,14 @@ public class LanTcpPluginTest extends BrambleTestCase {
ss.bind(new InetSocketAddress(addrString, 0), 10);
CountDownLatch latch = new CountDownLatch(1);
AtomicBoolean error = new AtomicBoolean(false);
new Thread() {
@Override
public void run() {
new Thread(() -> {
try {
ss.accept();
latch.countDown();
} catch (IOException e) {
error.set(true);
}
}
}.start();
}).start();
// Tell the plugin about the port
BdfList descriptor = new BdfList();
descriptor.add(TRANSPORT_ID_LAN);

View File

@@ -91,9 +91,7 @@ public class BriarService extends Service {
b.setPriority(PRIORITY_MIN);
startForeground(ONGOING_NOTIFICATION_ID, b.build());
// Start the services in a background thread
new Thread() {
@Override
public void run() {
new Thread(() -> {
String nickname = databaseConfig.getLocalAuthorName();
StartResult result = lifecycleManager.startServices(nickname);
if (result == SUCCESS) {
@@ -107,8 +105,7 @@ public class BriarService extends Service {
showStartupFailureNotification(result);
stopSelf();
}
}
}.start();
}).start();
}
private void showStartupFailureNotification(StartResult result) {
@@ -155,12 +152,9 @@ public class BriarService extends Service {
LOG.info("Destroyed");
stopForeground(true);
// Stop the services in a background thread
new Thread() {
@Override
public void run() {
new Thread(() -> {
if (started) lifecycleManager.stopServices();
}
}.start();
}).start();
}
@Override

View File

@@ -123,9 +123,7 @@ public class BriarControllerImpl implements BriarController {
@Override
public void signOut(ResultHandler<Void> eventHandler) {
new Thread() {
@Override
public void run() {
new Thread(() -> {
try {
// Wait for the service to finish starting up
IBinder binder = serviceConnection.waitForBinder();
@@ -140,8 +138,7 @@ public class BriarControllerImpl implements BriarController {
LOG.warning("Interrupted while waiting for service");
}
eventHandler.onResult(null);
}
}.start();
}).start();
}
private void unbindService() {