< Java多线程设计模式>> 一书
源代码在线查看: myframe.java
import java.io.IOException;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JButton;
public class MyFrame extends JFrame implements ActionListener {
public MyFrame() {
super("MyFrame");
getContentPane().setLayout(new FlowLayout());
getContentPane().add(new JLabel("Thread-Per-Message Sample"));
JButton button = new JButton("Execute");
getContentPane().add(button);
button.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
Service.service();
}
}