多线程
加木Go
技术教会我生活
展开
-
Java并发包中的几种ExecutorService
Java并发包中的几种ExecutorService转载 http://wawlian.iteye.com/blog/1315256 1.CachedThreadPool CachedThreadPool首先会按照需要创建足够多的线程来执行任务(Task)。随着程序执行的过程,有的线程执行完了任务,可以被重新循环使用时,才不再创建新的线程来执行任务。我们采用《Thinki转载 2012-06-30 15:09:21 · 552 阅读 · 0 评论 -
ExecutorService线程池
ExecutorService线程池 转载http://blog.sina.com.cn/s/blog_6151984a0100krj8.html ExecutorService 建立多线程的步骤: 1。定义线程类 class Handler implements Runnable{ } 2。建立ExecutorService线程池 Ex转载 2012-06-30 14:55:48 · 441 阅读 · 0 评论 -
古老的线程方法对比
new Thread(){ public void run(){ while(true){ Thread.sleep(2000); System.out.println(T hread.currentThread ().getName()); } } }.start(); new Thread( new Runnable(){ public void run(){原创 2012-06-30 19:04:55 · 366 阅读 · 0 评论 -
自动装箱
java中所有的东西几乎都是对象,但基本数据类型不是对象, 但有时需要将基本数据类型转换为对象。 例如Map操作put()方法传入的参数是对象而不是基本数据类型 自动装箱 将基本数据类型——》对象 自动装箱 将对象——》基本数据类型 方法: (1)Integer data=10; syso(data.doubleValue()/原创 2012-06-29 10:11:59 · 389 阅读 · 0 评论