public static void main(String[] args) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar c=Calendar.getInstance(); System.out.println(sdf.format(c.getTime())); c.add(Calendar.HOUR_OF_DAY, -1);//1小时前抄 System.out.println(sdf.format(c.getTime())); c=Calendar.getInstance(); c.add(Calendar.MINUTE, -1);//1分钟zhidao前 System.out.println(sdf.format(c.getTime())); }。
蓝玥凤羽 2020-04-24 01:14:10
class MyThread implements Runnable {public void run() {for(int i=0;i<20;i++) {System.out.println(Thread.currentThread().getName()+" "+i);try {Thread.sleep(60000);} catch(InterruptedException e) {return;}}}}public class TestSleep {public static void main(String[] args) {MyThread m = new MyThread();Thread t = new Thread(m,"A");Thread r = new Thread(m,"B");t.start();r.start();}}。
少年不哭 2020-05-03 05:31:33
使用多线程吧。是HTTP请求还是Socket请求?
以下仅供参考
package com.kidd.test.zhidao;import java.io.IOException;import java.net.MalformedURLException;import java.net.Socket;import java.net.URL;import java.net.URLConnection;import java.net.UnknownHostException;import com.mashape.unirest.http.Unirest;import com.mashape.unirest.http.exceptions.UnirestException;/** * Hello world! * */public class Main {public static void main(String[] args) {Mainthread mainthread;Thread thread;for (int i = 0; i
╭ァ随风而去。 2020-05-09 06:19:03
long startTime=System.currentTimeMillis(); boolen bo=true;while(bo=true){ long endTime=System.currentTimeMillis(); //获取当前毫秒数复 if((endTime-startTime)=60*1000) bo=false; //若超过一分钟则跳出制 /*你要调用的方百法*/ //在这里写度你要调用的方法。
}也可问以用Thread做。
都差不多,我就不写答了。
喵喵灬萝莉 2020-05-12 10:17:05