当前位置: 技术问答>java相关
Thread.sleep(1000)是什么意思?有什么作用?
来源: 互联网 发布时间:2015-02-14
本文导语: 一段进度条的程序,其中主程序里有Thread.sleep(1000)是什么意思?有什么作用? import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Progress extends JFrame { JProgressBar current; JTextArea out; ...
一段进度条的程序,其中主程序里有Thread.sleep(1000)是什么意思?有什么作用?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Progress extends JFrame {
JProgressBar current;
JTextArea out;
JButton find;
Thread runner;
int num = 0;
public Progress() {
super("Progress");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane = new JPanel();
pane.setLayout(new FlowLayout());
current = new JProgressBar(0, 2000);
current.setValue(0);
current.setStringPainted(true);
pane.add(current);
setContentPane(pane);
}
public void iterate() {
while (num
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Progress extends JFrame {
JProgressBar current;
JTextArea out;
JButton find;
Thread runner;
int num = 0;
public Progress() {
super("Progress");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane = new JPanel();
pane.setLayout(new FlowLayout());
current = new JProgressBar(0, 2000);
current.setValue(0);
current.setStringPainted(true);
pane.add(current);
setContentPane(pane);
}
public void iterate() {
while (num