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

  • SEARCH
  • Home
  • 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 6253537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:01:01+00:00 2026-05-24T14:01:01+00:00

I need advice is this solution acceptable and not cause overflow, I update data

  • 0

I need advice is this solution acceptable and not cause overflow, I update data which read with AsyncTask, after AsyncTask finished I need to update again and again. Is this solution acceptable and safe

private class DownloadFilesTask extends AsyncTask<URL,Integer,com.ring_view.www.json.System> {

    @Override
    protected com.ring_view.www.json.System doInBackground(URL... params) {
        int count = params.length;
         URL temp=params[0];
         System system=null;
        try {
            system = Communicator.getSystem(temp);
        } catch (LoggingConnectionException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (JSONParsingErrorException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

         return system;
    }

     protected void onProgressUpdate(Integer... progress) {
         //setProgressPercent(progress[0]);
     }

     protected void onPostExecute(com.ring_view.www.json.System result) {
         txtWorkAllowedValue.setText(result.work_allowed);
         try {
            new DownloadFilesTask().execute(new URL("http://test/status-system.json"));
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
     }

 }

I first time call new DownloadFilesTask().execute(new URL(“http://test/status-system.json&#8221;)); in OvCreate method and it works fine in emulator. Is this safe or there is some more elegant solution ?

  • 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-24T14:01:01+00:00Added an answer on May 24, 2026 at 2:01 pm

    Yes, instantiating an AsyncTask multiple times is acceptable, example…

    new DownloadFilesTask().execute(...);
    ...
    new DownloadFilesTask().execute(...);
    

    …is allowed.

    You must not do something like the following though…

    DownloadFilesTask myTask = new DownloadFilesTask();
    myTask.execute(...); // This is OK
    myTask.execute(...); // This will cause an exception
    

    This is because it isn’t legal to execute the same thread twice. In the first example using new repeatedly creates a new thread for doInBackground(...) but in the second example it is trying to re-use the previous one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need advice on how to return a limited set of data from an
I need some advice regarding how to organize my data for effective and fast
To be perfectly clear, I do not expect a solution to this problem. A
I need some advice when it comes to solving a sorting algorithm. This particular
Update and Solution I finally got everything working after 1. Uninstalling everything ruby-related in
I need advice on how to have my C# console application display text to
I need advice regarding subselect performance in MySQL. For a reason that I can't
I need some advice as to how I easily can separate test runs for
I need some expect advice on how to handle the following:- I have a
Need a little advice here. We do some windows mobile development using the .NET

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.