Several threads are created in the loop.
// Открыли соединение с базой for (int i = 0; i < 3; i++) { new Thread(new Runnable() { public void run(){ // Выполнили обращение к базе } }).start(); } // Закрыли соединение с базой
If I try to close the connection to the database before the call is made from one of the threads, an exception is thrown. How to wait for the completion of all threads?