コミットメタ情報

リビジョンaa92e5a9995704187fe063cdcc6330ed0fec0100 (tree)
日時2014-12-01 22:08:45
作者argius <argius.net@gmai...>
コミッターargius

ログメッセージ

use static AnyAction.doPallel instead of using
DaemonThreadFactory.execute directly

変更サマリ

差分

--- a/src/net/argius/stew/ui/window/AnyAction.java
+++ b/src/net/argius/stew/ui/window/AnyAction.java
@@ -3,16 +3,14 @@ package net.argius.stew.ui.window;
33 import static java.awt.event.KeyEvent.VK_Y;
44 import static java.awt.event.KeyEvent.VK_Z;
55 import static javax.swing.KeyStroke.getKeyStroke;
6-
76 import java.awt.*;
87 import java.awt.event.*;
98 import java.lang.reflect.*;
109 import java.util.*;
11-
10+import java.util.concurrent.*;
1211 import javax.swing.*;
1312 import javax.swing.text.*;
1413 import javax.swing.undo.*;
15-
1614 import net.argius.stew.*;
1715
1816 /**
@@ -20,6 +18,9 @@ import net.argius.stew.*;
2018 */
2119 final class AnyAction extends AbstractAction implements Runnable {
2220
21+ /** Thread Pool using Daemon Thread */
22+ private static final ExecutorService threadPool = Executors.newCachedThreadPool(DaemonThreadFactory.getInstance());
23+
2324 /** AnyActionListener, JComponent, or JTextComponent */
2425 private Object o;
2526
@@ -66,7 +67,11 @@ final class AnyAction extends AbstractAction implements Runnable {
6667
6768 void doParallel(String methodName, final Object... args) {
6869 final String label = "AnyAction#doParallel";
69- DaemonThreadFactory.execute(new Task(label, o, resolveMethod(methodName), args));
70+ doParallel(new Task(label, o, resolveMethod(methodName), args));
71+ }
72+
73+ static void doParallel(Runnable runnable) {
74+ threadPool.execute(runnable);
7075 }
7176
7277 private static final class Task implements Runnable {
--- a/src/net/argius/stew/ui/window/DatabaseInfoTree.java
+++ b/src/net/argius/stew/ui/window/DatabaseInfoTree.java
@@ -616,7 +616,7 @@ final class DatabaseInfoTree extends JTree implements AnyActionListener, TextSea
616616 invokeLater(new Task2());
617617 }
618618 }
619- DaemonThreadFactory.execute(new NodeExpansionTask());
619+ AnyAction.doParallel(new NodeExpansionTask());
620620 }
621621
622622 /**
--- a/src/net/argius/stew/ui/window/ResultSetTableModel.java
+++ b/src/net/argius/stew/ui/window/ResultSetTableModel.java
@@ -408,7 +408,7 @@ final class ResultSetTableModel extends DefaultTableModel {
408408 latch.countDown();
409409 }
410410 }
411- DaemonThreadFactory.execute(new SqlTask());
411+ AnyAction.doParallel(new SqlTask());
412412 try {
413413 // waits for a task to stop
414414 latch.await(3L, TimeUnit.SECONDS);
@@ -429,7 +429,7 @@ final class ResultSetTableModel extends DefaultTableModel {
429429 }
430430 }
431431 }
432- DaemonThreadFactory.execute(new SqlTaskErrorHandler());
432+ AnyAction.doParallel(new SqlTaskErrorHandler());
433433 } else if (!errors.isEmpty()) {
434434 if (log.isDebugEnabled()) {
435435 for (final Exception ex : errors) {
旧リポジトリブラウザで表示