M
Michael Powe
Hello,
I have a simple GUI that runs some methods from a class that formerly
was part of a commandline application. Execution of the methods works
fine but sometimes freezes the UI until completion. In addition, I
start a logger when the application is loaded (GUI fires up), and the
logging seems to die before completing.
My thought is that the GUI freezes because the processing taking place
in the method is in the same thread as the GUI. I am a bit puzzled
about the logging, though. The file output stops in the middle of a
line, as though the logger exited before completing the output.
From what I've read, using threads in a GUI application is tricky, and
I'm ignorant of threads, anyway. So, I'm asking for confirmation that
my thought about the freeze is correct, and suggestions about what
might be happening with the logging and how I can "spin off" the
method processing safely.
If it matters, this application is starting and stopping Windows
services via "net start" and "net stop" system commands; and logging
the output.
Thanks.
mp
Here's the main class:
public class Main {
public static void main(String[] args) {
ControlServices.createLogger();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
RestartWt7UI ui = new RestartWt7UI();
ui.setSize(500,300);
ui.setVisible(true);
}
});
}
}
I have a simple GUI that runs some methods from a class that formerly
was part of a commandline application. Execution of the methods works
fine but sometimes freezes the UI until completion. In addition, I
start a logger when the application is loaded (GUI fires up), and the
logging seems to die before completing.
My thought is that the GUI freezes because the processing taking place
in the method is in the same thread as the GUI. I am a bit puzzled
about the logging, though. The file output stops in the middle of a
line, as though the logger exited before completing the output.
From what I've read, using threads in a GUI application is tricky, and
I'm ignorant of threads, anyway. So, I'm asking for confirmation that
my thought about the freeze is correct, and suggestions about what
might be happening with the logging and how I can "spin off" the
method processing safely.
If it matters, this application is starting and stopping Windows
services via "net start" and "net stop" system commands; and logging
the output.
Thanks.
mp
Here's the main class:
public class Main {
public static void main(String[] args) {
ControlServices.createLogger();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
RestartWt7UI ui = new RestartWt7UI();
ui.setSize(500,300);
ui.setVisible(true);
}
});
}
}