package myGUI;import java.awt.EventQueue;
import java.lang.reflect.InvocationTargetException;import javax.swing.JButton;import javax.swing.JFrame;public class InvokerLater extends JFrame {
/**
* 主应用窗口,
*/
public static void main(String args[]) {
try {
EventQueue.invokeAndWait(new Runnable(){ @Override
public void run() {
for(int j=0;j<500000;j++)
System.out.println("j = asdf" + j);
}});
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("out main");
for(int i=0;i<50000;i++)
System.err.println("out main circle"+i/3.3);
//始终得不到执行。一定要invokeAndWait方法执行完了才行。
} /**
* Create the frame
*/
public InvokerLater() {
super();
setJMenuBar(null);
getContentPane().setLayout(null);
setBounds(100, 100, 600, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button = new JButton();
button.setText("播放");
button.setBounds(465, 34, 106, 28);
getContentPane().add(button); final JButton button_1 = new JButton();
button_1.setText("暂停");
button_1.setBounds(465, 129, 106, 28);
getContentPane().add(button_1);
}}
import java.lang.reflect.InvocationTargetException;import javax.swing.JButton;import javax.swing.JFrame;public class InvokerLater extends JFrame {
/**
* 主应用窗口,
*/
public static void main(String args[]) {
try {
EventQueue.invokeAndWait(new Runnable(){ @Override
public void run() {
for(int j=0;j<500000;j++)
System.out.println("j = asdf" + j);
}});
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("out main");
for(int i=0;i<50000;i++)
System.err.println("out main circle"+i/3.3);
//始终得不到执行。一定要invokeAndWait方法执行完了才行。
} /**
* Create the frame
*/
public InvokerLater() {
super();
setJMenuBar(null);
getContentPane().setLayout(null);
setBounds(100, 100, 600, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button = new JButton();
button.setText("播放");
button.setBounds(465, 34, 106, 28);
getContentPane().add(button); final JButton button_1 = new JButton();
button_1.setText("暂停");
button_1.setBounds(465, 129, 106, 28);
getContentPane().add(button_1);
}}
API是这么说的。没有说它怎么霸道啊。