标签:test gen over 线程同步 public 集合 date barrier 空中网
传统线程技术回顾
public class TraditionalThread { /** * @param args */ public static void main(String[] args) { //第一种:new Thread() Thread thread = new Thread(){ @Override public void run() { while(true){ try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("1:" + Thread.currentThread().getName()); System.out.println("2:" + this.getName()); } } }; thread.start(); Thread thread2 = new Thread(new Runnable(){ @Override public void run() { while(true){ try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("1:" + Thread.currentThread().getName()); } } }); thread2.start(); //第二种:new Runnable() new Thread( new Runnable(){ public void run() { while(true){ try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("runnable :" + Thread.currentThread().getName()); } } } ){ public void run() { while(true){ try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("thread :" + Thread.currentThread().getName()); } } }.start(); } }
传统定时器技术回顾
import java.util.Date; import java.util.Timer; import java.util.TimerTask; public class TraditionalTimerTest { private static int count = 0; public static void main(String[] args) { /* new Timer().schedule(new TimerTask() { @Override public void run() { System.out.println("bombing!"); } }, 10000,3000);*/ class MyTimerTask extends TimerTask{ @Override public void run() { count = (count+1)%2; System.out.println("bombing!"); new Timer().schedule(/*new TimerTask() { @Override public void run() { System.out.println("bombing!"); } }*/new MyTimerTask(),2000+2000*count); } } new Timer().schedule(new MyTimerTask(), 2000); while(true){ System.out.println(new Date().getSeconds()); try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
传统线程互斥技术
传统线程同步通信技术
线程范围内共享变量的概念与作用
ThreadLocal类及应用技巧
多个线程之间共享数据的方式探讨
java5原子性操作类的应用
java5线程并发库的应用
Callable与Future的应用
java5的线程锁技术
java5读写锁技术的妙用
java5条件阻塞Condition的应用
java5的Semaphere同步工具
java5的CyclicBarrier同步工具
java5的CountDownLatch同步工具
java5的Exchanger同步工具
java5阻塞队列的应用
java5同步集合类的应用
空中网挑选实习生的面试题1
空中网挑选实习生的面试题2
空中网挑选实习生的面试题3
标签:test gen over 线程同步 public 集合 date barrier 空中网
原文地址:http://www.cnblogs.com/xuyatao/p/6718717.html