@Override public void run() { try { ServerSocket server = new ServerSocket(listenPort); // 开始循环 while (true) { Socket socket = server.accept(); cs.submit(new HandleThread(socket)); try { UploadObject result = cs.take().get(); // 如何实现接收完文件后上传到服务器ftp,因为这是多线程,如果有回调方法可能比较好 try { FtpUploadFiles ftpUploadFiles = FtpUploadFiles.getInstance(); PathManage pathManage = FilePathConstants.pathMap.get(result.getFileType()); if (pathManage != null && !pathManage.getFileType().equals(FileType.TempDataType)) { String tpFtpDir = pathManage.getFtpPath(); if (result.getCreateDir() != null) { tpFtpDir += result.getCreateDir(); } ftpUploadFiles.uploadMmsFile(result.getPath(), result.getNewLocalFile(), tpFtpDir); } } catch (Exception e) { e.printStackTrace(); } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } } catch (IOException e) { e.printStackTrace(); } }