⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filelist.java

📁 JAVA实现的网络服务器文件同步
💻 JAVA
字号:
package com.msd;

import java.util.List;
import java.util.LinkedList;

public class FileList {

   private List filePool = null;
   private static FileList instance = null;

   private FileList() {
      filePool = new LinkedList();
   }

   public synchronized static void create() {
      if(instance == null) 
		 instance = new FileList();
   }

   public static FileList getInstance() {
      if(instance == null)
		 throw new NullPointerException("FileList is null");
	  return instance;
   }

   public void addFile(SendFile fileName) {
      synchronized(filePool) {
         filePool.add(filePool.size(),fileName);
         filePool.notifyAll();
      }
   }

   public SendFile getFile() {
	  SendFile fileName = null;
      synchronized(filePool) {
         while(filePool.isEmpty()) {
            try{
               filePool.wait();
            } catch(InterruptedException e) {   }
         }
         fileName = (SendFile)filePool.remove(0);
      }
	  return fileName;
   }

}
class SendFile {

	String fileName;	
	int flag;

	public SendFile(String f,int g) {
		fileName = f;
		flag = g;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -