日期:2014-05-17 浏览次数:20700 次
Thread thread_a = new Thread(new Thread_a()); Thread thread_b = new Thread(new Thread_b()); Thread thread_c = new Thread(new Thread_c)); thread_a.start(); thread_b.start(); thread_c.start(); public class Thread_a implements Runnable { public void run() { while (true) { .....//具体业务逻辑 Thread.sleep(1000*10); } } } public class Thread_b implements Runnable { public void run() { while (true) { .....//具体业务逻辑 Thread.sleep(1000*100); } } } public class Thread_c implements Runnable { public void run() { while (true) { .....//具体业务逻辑 Thread.sleep(1000*200); } } }
URL url = new URL("http://www.baidu.com"); URLConnection conn = url.openConnection(); conn.setConnectTimeout(10);//连结超时,单位毫秒 conn.setReadTimeout(10);//读超时 conn.getInputStream();//获得流 = url.openStream();