This code is executed on a background service every 60 seconds on an Android app. Each class instantiated on FutureTask (WifiInfoFetch and WifiApResults) contains an insert to an SQLite database. We changed the original implementation (without a FutureTask) as we think the first insert was still locking the database when the second one tried to do its insert as they were executed very close to each other.I think that with the code below, the second thread should wait until the first one is finished to start. Is this true? Also, what happens if for any reason thread 1 does not finish? Is there a way to set a timeout to interrupt it?WifiInfo wifi = wifiManager.getConnectionInfo();if (wifi == null) return;WifiInfoFetch wifiInfo = new WifiInfoFetch(getApplicationContext(), wifi);WifiApResults scanResults = new WifiApResults(getApplicationContext(), wifiManager.getScanResults());FutureTask<String> futureWifiInfo = new FutureTask<>(wifiInfo);FutureTask<String> futureScanResults = new FutureTask<>(scanResults);ExecutorService executor = Executors.newFixedThreadPool(2);try {    executor.submit(futureWifiInfo).get();    executor.submit(futureScanResults);} catch (InterruptedException e) {    e.printStackTrace();} catch (ExecutionException e) {    e.printStackTrace();}Thanks!
FutureTask in Android, wait for a thread to execute the next one
java;multithreading;android