线程的做的时间表,不知道合不合适,哪位还有更好的实现方式(java)烦赐教!
package Thread;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TestSleep


{
public static void main(String[] args)

{
new MyThread().start();
}
}

class MyThread extends Thread


{
public void run()

{
while(true)

{
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
String date = "现在时间是-->"+sdf.format(new Date());
System.out.println("****"+date+"****");
try

{
sleep(1000);
}
catch(InterruptedException ie)

{
return;
}
}
}
}
package Thread;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TestSleep 

{
public static void main(String[] args) 
{
new MyThread().start();
}
}
class MyThread extends Thread

{
public void run()
{
while(true)
{
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
String date = "现在时间是-->"+sdf.format(new Date());
System.out.println("****"+date+"****");
try
{
sleep(1000);
}
catch(InterruptedException ie)
{
return;
}
}
}
}
1603

被折叠的 条评论
为什么被折叠?



