class ShowGra implements Runnable
{
private int percent;
public ShowGra(int per)
{
this.percent = per;
}
public void run(){
int i;
for(int j=0;j<30;j++)
System.out.print("\b");
for(i=0;i<percent/5;i++)
{
System.out.print("=");
}
int blanks = 25-i;
for(int k=0;k<blanks;k++)
System.out.print(" ");
System.out.printf("%3d%%",percent);
}
}
public class Test
{
public Test()
{
}
public static void main(String[] args)
{
int per = 0;
while(per<=100){
Runnable run2 = new ShowGra(per);
Thread thread2 = new Thread(run2);
thread2.start();
try{
Thread.sleep(1000);
}catch(Exception e)
{
;
}
finally{
per+=5;
}
}
}
}
java 命令行中显示进度信息
最新推荐文章于 2024-09-26 11:22:21 发布