문제

I am developing my own simple logging system, which I'd like to design so it writes the to output stream asyncronously. For that purpose I create processing thread. How am I supposed to properly stop it, when user application finishes executing?

Unfortunatelly SLF4J facade doesn't provide any interface for me to delegate this responsibility to the user.

도움이 되었습니까?

해결책

Make the thread daemon and it will finish togehter with the application. As for closing the OutputStream you don't need to worry about it. If it is a file or a socket it will be closed by OS anyway. Just make sure you flush after each write.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top