java一分钟求婚卡怎么做

最佳回答
Thread.sleep(1000*60);参数单位是毫秒
更多回答

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())); }。

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();}}。

使用多线程吧。是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 < 2000; i++) { mainthread = new Mainthread("线程" + i); thread = new Thread(mainthread); thread.start(); } }}class Mainthread implements Runnable { private String name; public Mainthread(String name) { this.name = name; } @Override public void run() { Socket socket = null; try { socket = new Socket("www.baidu.com", 80); System.out.println(name + "连接成功."); } catch (UnknownHostException e) { System.out.println(name + "连接失败."); } catch (IOException e) { System.out.println(name + "连接失败."); } try { if (socket != null && !socket.isClosed()) { socket.close(); } } catch (IOException e) { } }}

long startTime=System.currentTimeMillis(); boolen bo=true;while(bo=true){ long endTime=System.currentTimeMillis(); //获取当前毫秒数复 if((endTime-startTime)=60*1000) bo=false; //若超过一分钟则跳出制 /*你要调用的方百法*/ //在这里写度你要调用的方法。

}也可问以用Thread做。

都差不多,我就不写答了。

登陆
发送验证码
用手机验证码登录
前往注册
特一官网客服热线

客服热线

值班热线

特一官网微信客服号

微信客服号

LMJX5588

特一官网QQ客服

QQ客服

1781567112

点击对话

收起
特一 QQ客服号 特一微信客服号 官方电话 返回顶部

全国浪漫热线

值班热线

特一官网微信客服号

微信扫描加好友