Java??????????????
?????Linux??? ???????[ 2017/4/25 11:00:26 ] ??????????????????? JAVA
	????java ???????????????
	??????java?У???????????????????????????????????Thread????дrun???????????????????Runnable???????дrun????????????????????Callable??????дcall???????????????????????????????????????????????????ο?????
	????(1)???Thread????дrun??????
	class xx extends Thread{
	public void run(){
	Thread.sleep(1000)  //???????1000????sleep???????Block????????????
	}}
	????????????
	????????.start()    //???????run????????
	??????2?????Runnable????????????
	class MyThread implements Runnable {
	private String name;
	public MyThread(String name) {
	super();
	this.name = name;
	}
	@Override
	public void run() {
	for(int i = 0 ; i < 200; i++) {
	System.out.println("Thread"+name+"--->"+i);
	}
	}
	}
	public class ThreadDemo {
	public static void main(String[] args) {
	MyThread a = new MyThread("a");
	MyThread b = new MyThread("b");
	MyThread c = new MyThread("c");
	new Thread(a).start();
	new Thread(b).start();
	new Thread(c).start();
	}
	}
	????(3)???Callable??????дcall????
	????Callable????????Runnable????????Callable??????????Runnable?????????????????е?????
	????Callable??Runnable?м????:
	????Callable?漲???????call()????Runnable?漲???????run().
	????Callable????????к??????????Runnable?????????????????
	????call()???????????????run()?????????????????
	????????Callable???????????Future????Future???????????????????????????????????????????????????????????????.???Future????????????????????????????????У?????????????е???
	????Java  Callable ?????????
	class TaskWithResult implements Callable<String> {
	private int id;
	public TaskWithResult(int id) {
	this.id = id;
	}
	@Override
	public String call() throws Exception {
	return "result of TaskWithResult " + id;
	}
	}
	public class CallableTest {
	public static void main(String[] args) throws InterruptedException??
	ExecutionException {
	ExecutorService exec = Executors.newCachedThreadPool();
	ArrayList<Future<String>> results = new ArrayList<Future<String>>(); //Future ?????????????Executor??е????????????
	for (int i = 0; i < 10; i++) {
	results.add(exec.submit(new TaskWithResult(i)));
	}
	for (Future<String> fs : results) {
	if (fs.isDone()) {
	System.out.println(fs.get());
	} else {
	System.out.println("Future result is not yet complete");
	}
	}
	exec.shutdown();
	}
	}
	??????л???????????????????лл????????????
??????
					
					???·???
App??С????H5?????????????????Щ??
2024/9/11 15:34:34?????????????????????????
2024/9/10 11:13:49P-One ???????????????????????????????????????
2024/9/10 10:14:12???????????????????????????
2024/9/9 18:04:26??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44
					
			
								
								
								
								
								
								
								
								
								
								
				
sales@spasvo.com