Hi all, I have two threads let's say thread1 and thread2 connecting, listing, uploading and downloading files from specific folders from a remote Linux system. The threads are time-based triggers that mean they run on some random interval of time (for every hour or every day etc.,) I have created a new class SFTPMinaClientConnector.java which has connect() and disconnect() methods in it in addition to methods for listFiles(), download(), upload() etc., As the threads call SFTPMinaClientConnector.java (is a prototype bean) very rarely and with a good amount of time gap I am connecting the connections with all the session and other resources. For these reasons, I am closing all the resources once I am done. Both of the threads use the same user. If the two threads trigger at the same time, while thread2 is in connect() method thread1 has already closed the resources using close() method which lead to Connection already closed exception for thread1. I am using the following statement for getting the connections, *ConnectFuture connectFuture = _client.connect(_username, _host, portNumber); *
My questions are, (1) Do the connections get cached for every user? (2) How can I have a different connection object for the same user? As per the chat here - https://issues.apache.org/jira/browse/SSHD-935 looks like I need to make sure from my end that the connection is not getting closed until all threads are done. (3) Can I return the client object from connect() method so that every thread can call client.wait() and then call client.notify()? Does doing this help other threads not to do anything while other threads are engaged in working with client object and save me from this situation? I am planning something like below, [image: image.png] Thanks, Zabee
