java的同步和异步简单的使用个方法
--异步
Thread t3 = new Thread(new Runnable() {
@Override
public void run() {
try {
for (int i = 0; i < 10; i++) {
Thread.sleep(1100);
System.out.println("4:"
+ i);
}
} catch (Exception e) {
e.printStackTrace();
}
}
});t3.start();
--同步
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
}
});
t3.isAlive()