Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5970343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:21:42+00:00 2026-05-22T20:21:42+00:00

I use FTP raw commands to upload file to a FTP server, I start

  • 0

I use FTP raw commands to upload file to a FTP server, I start a new thread to send file via socket in my code. when the newly started thread finished sending file I want to output some message to console, how can I make sure the thread have finished it’s work ?
here is my code:

TinyFTPClient ftp = new TinyFTPClient(host, port, user, pswd);
ftp.execute("TYPE A");
String pasvReturn = ftp.execute("PASV");
String pasvHost = TinyFTPClient.parseAddress(pasvReturn);
int pasvPort = TinyFTPClient.parsePort(pasvReturn);
new Thread(new FTPFileSender(pasvHost, pasvPort, fileToSend)).start();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:21:43+00:00Added an answer on May 22, 2026 at 8:21 pm

    how can I make sure the thread have finished it’s work ?

    You do call Thread.join() like this:

    ...
    Thread t = new Thread(new FTPFileSender(pasvHost, pasvPort, fileToSend));
    t.start();
    
    // wait for t to finish
    t.join();
    

    Note however that Thread.join will block until the other thread has finished.

    A better idea is perhaps to encapsulate the upload-thread in a UploadThread class which performs some callback when it’s done. It could for instance implement an addUploadListener and notify all such listeners when the upload is complete. The main thread would then do something like this:

    UploadThread ut = new UploadThread(...);
    ut.addUploadListener(new UploadListener() {
        public void uploadComplete() {
            System.out.println("Upload completed.");
        }
    });
    
    ut.start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how to use CruiseControl.Net to publish to an FTP server?
I use ftp_put / ftp_nb_put to upload files from my PHP server to another
I am using the code below to upload an image through ftp $sFile=$ftp_dir./.$image_name; $image=$database_row[image];//image
I would like to use the same code for copying files to an FTP
I use FTP on a daily basis to work on multiple websites, but when
I want to use the FTP task in ant, and I have found the
You can use ftplib for full FTP support in Python. However the preferred way
Use case: 3rd party application wants to programatically monitor a text file being generated
I use rsync to synchronize files to Windows clients in a server agnostic way.
I'm trying to use ftp_connect('ftp.is.co.za') [for example] in PHP 5 or higher (multiple different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.