package com.yangmuyao.utils;

import java.io.File;
import java.io.Serializable;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by fengyuyangchen on 16/6/14.
 */
public class FilePool  implements Serializable{

    private     static Map<String ,CacheFile>    filepool = new ConcurrentHashMap<String, CacheFile>();
    public      static Map<String ,CacheFile>    getAllFiles(){
        return filepool;
    }

    /**
     *
     * @param thread_id
     * @return
     * @throws Exception
     */
    public      static CacheFile getFile(long thread_id) throws Exception{

        String key = String.valueOf(thread_id);

        if ( !filepool.containsKey(key) || filepool.isEmpty() ){

            //filename
            String uuid                         = "tmp" + File.separator + UUID.randomUUID().toString();
            CacheFile               cacheFile   = new CacheFile(uuid);

            filepool.put(key,cacheFile);

            return cacheFile;
        }else {
            return filepool.get(key);
        }
    }


}

@@ -23,16 +23,40 @@
 utils;%0A%0A
+import sun.misc.Queue;%0A%0A
 import j
@@ -93,24 +93,53 @@
 rializable;%0A
+import java.util.Collection;%0A
 import java.
@@ -217,16 +217,67 @@
 HashMap;
+%0Aimport java.util.concurrent.ConcurrentLinkedQueue;
 %0A%0A/**%0A *
@@ -568,16 +568,122 @@
 %0A    %7D%0A%0A
+    public      static ConcurrentLinkedQueue%3CString%3E  fileHistory = new ConcurrentLinkedQueue%3CString%3E();%0A%0A
     /**%0A
@@ -1193,16 +1193,50 @@
 eFile);%0A
+            fileHistory.add(uuid);
 %0A       

add filelist cache