JDK5.0特性-线程 Callable和Future】的更多相关文章

来自:http://www.cnblogs.com/taven/archive/2011/12/17/2291466.html import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; /** 从本节开始,主要介绍J2SE5.0与线程相关的新…
来自:http://www.cnblogs.com/taven/archive/2011/12/17/2291469.html import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util…
来自:http://www.cnblogs.com/taven/archive/2011/12/17/2291470.html import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.locks.Lock; import java.util.concurren…
来自:http://www.cnblogs.com/taven/category/475298.html import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** * CountDownLatch维护一个计数器,等待这个CountDownLatch的线程必须等到计数器为0时才可以继续. * 以…
来自:http://www.cnblogs.com/taven/archive/2011/12/17/2291474.html import java.util.ArrayList; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Semaphore; import java.util.concurrent.locks.L…
来自:http://www.cnblogs.com/taven/archive/2011/12/17/2291471.html import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.…
1.概述 1.1 JDK1.5后,Java提供了Callable接口,该接口提供一个call方法作为线程执行体,该call方法可以  有返回值.声明抛出异常: 因此,我们可以直接将Callable接口作为target来创建线程,但是:Callable接口是新增的接口,不是Runnable的实现类: JDK1.5后又提供了Future接口,并提供Future接口的实现类FutureTask(该类实现了Runnable接口,可以作为Thread的target): 1.2 创建.启动有返回值的线程:…
来自:http://www.cnblogs.com/taven/archive/2011/12/17/2291465.html import java.lang.management.ClassLoadingMXBean; import java.lang.management.CompilationMXBean; import java.lang.management.GarbageCollectorMXBean; import java.lang.management.ManagementF…
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.ut…
1 package cn.itcast.p4.news.demo; 2 3 public class ParamterDemo { 4 5 public static void main(String[] args) { 6 // TODO Auto-generated method stub 7 // int sum = add(4, 5); 8 // System.out.println("sum="+sum); 9 // int sum1 = add(4, 5, 6); 10 /…