What makes sense for JavaMail?
Create a Store connection for each request on the email server, and then close it immediately after the task completes.
Open a connection to the Store and only reconnect if the connection is closed by the server or the local application is completed.
Although (1) can lead to multiple calls to connect () and close () in a row, (2) can block resources, although this would not really be necessary (but IMAP / POP3 calls would be quick, since without additional. Connect () required).
source share