例如,如果是下午1点(13:00),我需要以毫秒为单位获得数字46800000(从开始日起13小时).有人可以帮忙吗?
如何从我创建的子线程中终止父(主)线程?我试过System.exit(1),但它只终止子线程.我也尝试在main的while循环中设置一个条件,但显然会在退出之前尝试读取1个额外的输入.
public static void main(String[] args) throws IOException
{
new Thread(new Runnable()
{
public void run()
{
while(true)
{
//meet a condition then terminate
}
}
}).start();
while (true)
{
String a = input.nextLine();
//do something with input
}
}
Run Code Online (Sandbox Code Playgroud)