Using streams in webapp is not a problem per se. It just depends on how and how you use them. In particular, if you have 1000 users and you start one thread for each of these users, you will lift the JVM to its knees.
But if threads run very rarely, for a specific, reduced set of users and use cases, and if you use a thread pool to limit the number of such threads, you should not have any problems. It’s just important to understand what you are doing.
Also, be sure to pass the HttpServletRequest or HttpServletResponse object to such a stream, as they are not intended to be used by multiple parallel threads, and they should not be used anymore after calling the request.
source share