-Shutdown fix
This commit is contained in:
tonikelope 2016-10-26 18:47:40 +02:00
parent 6b5ac57673
commit 824394ba59
6 changed files with 74 additions and 22 deletions

View File

@ -520,14 +520,12 @@ public final class Download implements Transference, Runnable, SecureNotifiable
_thread_pool.shutdown();
while (!_thread_pool.isTerminated()) {
try {
try {
_thread_pool.awaitTermination(MAX_WAIT_WORKERS_SHUTDOWN, TimeUnit.SECONDS);
_thread_pool.awaitTermination(MAX_WAIT_WORKERS_SHUTDOWN, TimeUnit.SECONDS);
} catch (InterruptedException ex) {
getLogger(Download.class.getName()).log(SEVERE, null, ex);
}
} catch (InterruptedException ex) {
getLogger(Download.class.getName()).log(SEVERE, null, ex);
}
if (!_thread_pool.isTerminated()) {

View File

@ -335,7 +335,14 @@ public final class DownloadView extends javax.swing.JPanel implements Transferen
private void close_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_close_buttonActionPerformed
_download.close();
THREAD_POOL.execute(new Runnable() {
@Override
public void run() {
_download.close();
}
});
}//GEN-LAST:event_close_buttonActionPerformed
private void copy_link_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copy_link_buttonActionPerformed
@ -347,17 +354,39 @@ public final class DownloadView extends javax.swing.JPanel implements Transferen
private void restart_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_restart_buttonActionPerformed
_download.restart();
THREAD_POOL.execute(new Runnable() {
@Override
public void run() {
_download.restart();
}
});
}//GEN-LAST:event_restart_buttonActionPerformed
private void stop_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stop_buttonActionPerformed
_download.stop();
THREAD_POOL.execute(new Runnable() {
@Override
public void run() {
_download.stop();
}
});
}//GEN-LAST:event_stop_buttonActionPerformed
private void pause_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pause_buttonActionPerformed
_download.pause();
THREAD_POOL.execute(new Runnable() {
@Override
public void run() {
_download.pause();
}
});
}//GEN-LAST:event_pause_buttonActionPerformed
@Override

View File

@ -9,7 +9,6 @@ import java.util.List;
import java.util.Map;
import static java.util.logging.Level.SEVERE;
import static java.util.logging.Logger.getLogger;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreeNode;

View File

@ -58,7 +58,7 @@ import static megabasterd.Transference.MAX_TRANSFERENCE_SPEED_DEFAULT;
*/
public final class MainPanel {
public static final String VERSION = "1.42";
public static final String VERSION = "1.43";
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
public static final int STREAMER_PORT = 1337;
public static final int WATCHDOG_PORT = 1338;

View File

@ -734,14 +734,12 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
_thread_pool.shutdown();
while (!_thread_pool.isTerminated()) {
try {
try {
_thread_pool.awaitTermination(MAX_WAIT_WORKERS_SHUTDOWN, TimeUnit.SECONDS);
_thread_pool.awaitTermination(MAX_WAIT_WORKERS_SHUTDOWN, TimeUnit.SECONDS);
} catch (InterruptedException ex) {
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (InterruptedException ex) {
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
}
if (!_thread_pool.isTerminated()) {

View File

@ -335,22 +335,50 @@ public final class UploadView extends javax.swing.JPanel implements Transference
}//GEN-LAST:event_slots_spinnerStateChanged
private void close_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_close_buttonActionPerformed
_upload.close();
THREAD_POOL.execute(new Runnable() {
@Override
public void run() {
_upload.close();
}
});
}//GEN-LAST:event_close_buttonActionPerformed
private void restart_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_restart_buttonActionPerformed
_upload.restart();
THREAD_POOL.execute(new Runnable() {
@Override
public void run() {
_upload.restart();
}
});
}//GEN-LAST:event_restart_buttonActionPerformed
private void stop_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stop_buttonActionPerformed
_upload.stop();
THREAD_POOL.execute(new Runnable() {
@Override
public void run() {
_upload.stop();
}
});
}//GEN-LAST:event_stop_buttonActionPerformed
private void pause_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pause_buttonActionPerformed
_upload.pause();
THREAD_POOL.execute(new Runnable() {
@Override
public void run() {
_upload.pause();
}
});
}//GEN-LAST:event_pause_buttonActionPerformed