Java getOutputStream()已被称为Spring MVC

Java getOutputStream()已被称为Spring MVC,java,spring,multithreading,spring-mvc,Java,Spring,Multithreading,Spring Mvc,我们的要求是从FTP服务器上下载文件,我们使用一个接一个的顺序下载文件,这需要花费大量的时间 顺序代码: for(String mediaValue: generatedMediaTypes) { // Logic here is getting the user selected files from Ui and keep it in string array str try { ddownloadMultipleNavDbs(str[i]),uniqueID

我们的要求是从FTP服务器上下载文件,我们使用一个接一个的顺序下载文件,这需要花费大量的时间

顺序代码:

for(String mediaValue: generatedMediaTypes) {
    // Logic here is getting the user selected files from Ui and keep it in string array str
    try {
        ddownloadMultipleNavDbs(str[i]),uniqueID);
        //now we download all the files here with downloadfile logic with help of unique id we are a folder by that name and keep all this files in that folder
    } catch (Exception ex) {
        logger.error(ex.getMessage());
    }
}
将所有文件下载到uniqueID文件夹后,我现在压缩并通过
downloadZip(请求,uniqueID)
发送到客户端:

它在上面的代码中工作得非常好。 当我使用executorservice并行下载文件时

executorService.submit(new myThread(str[i]),uniqueID);
我面临错误:

getOutputStream()已关闭

谁能解释一下我为什么要面对这个错误


我们为什么要面对这个错误以及如何解决它?

请帮助我找到一个好的解决方案。我从一个星期以来一直在努力解决这个问题..并且没有使用executor service返回任何内容来查看或JSP您的输出流被第一个完成的线程关闭,当第二个线程尝试写入时,会抛出异常,为了避免这种情况,您只需要在所有文件都已写入或发生任何异常时关闭流。所有输出流都已正确关闭,但仍会收到此错误改进的语法格式您实际上是在不同线程中引用相同的输出流,这就是您收到异常的原因。
executorService.submit(new myThread(str[i]),uniqueID);