少年阿賓

          那些青春的歲月

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks
          方法一:

          package com.abin.lee.thread;

          import java.util.Iterator;
          import java.util.LinkedList;
          import java.util.List;
          public class ThreadSync{
           
           public static List<Object> ThreadSync(final String message) throws InterruptedException{
            final List<Object> list=new LinkedList<Object>();
            Thread thread=new Thread(){
             public void run(){
              if(message.equals("one")){
               list.add(0, message);
              }
             }
            };
            thread.start();
            thread.join();
            return list;
           }
           
           public static void main(String[] args) throws InterruptedException {
            List<Object> list=ThreadSync("one1");
            System.out.println("size="+list.size());
            for(Iterator it=list.iterator();it.hasNext();){
             Object obj=(Object)it.next();
             System.out.println("obj="+obj);
            }
            
           }
          }




          方法二:

          posted on 2012-12-07 10:36 abin 閱讀(681) 評論(0)  編輯  收藏 所屬分類: JavaMultithread
          主站蜘蛛池模板: 平江县| 周至县| 葵青区| 丹凤县| 增城市| 苗栗市| 石门县| 庆阳市| 灵丘县| 修水县| 阿拉尔市| 镇安县| 迭部县| 忻州市| 泰顺县| 随州市| 定安县| 嵩明县| 通江县| 南江县| 金乡县| 上蔡县| 祁门县| 固阳县| 青河县| 宾阳县| 建瓯市| 白沙| 洞口县| 临漳县| 鲁甸县| 射阳县| 彭阳县| 武平县| 西吉县| 涞水县| 邵阳市| 石门县| 湟源县| 和静县| 河东区|