usetime.java

来自「java 多线程文件下载器源代码......」· Java 代码 · 共 60 行

JAVA
60
字号
package com.sam.net.download;

class UseTime  implements Runnable
{
int time;
FormatTime formattime;
String usetime;
boolean status;

public UseTime(int status)
{
	time = 0;
	formattime = new FormatTime();
	if (status == 0)
		this.status = true;
	else
		this.status = false;
}

public void run()
{
	while (status) 
	{
		usetime = formattime.changTime(time);
		time++;
		try
		{
			Thread.sleep(1000L);
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
	}
}

public String getUseTime()
{
	return usetime;
}

public void getStatus(int status)
{
	if (status == 0)
		this.status = true;
	else
		this.status = false;
}

public void start(int status)
{
	Thread thread = new Thread(this);
	if (status == 0)
		this.status = true;
	else
		this.status = false;
	thread.start();
}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?