Apache Commons NET: Should I create a new FTPClient object on each connection or reuse one?

前端 未结 3 659
遇见更好的自我
遇见更好的自我 2021-01-12 05:08

I\'m just wondering: in my Java application, each time I need to connect to an FTP server, should I create a new FTPClient object, or should I create one FTPClient() object

3条回答
  •  终归单人心
    2021-01-12 05:32

    Both will work, but apache commons.net libraries are not thread safe, so if you do use one client with multiple threads, be aware that you'll have to synchronize access to it.

提交回复
热议问题