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 7990329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:58:34+00:00 2026-06-04T12:58:34+00:00

What is the less memory consuming and fastest (in respect of code lines and

  • 0

What is the less memory consuming and fastest (in respect of code lines and time of execution) way to do some task in the background thread?

I need to send many simple tasks to the background thread and I won’t obviously use AsyncTask class for this. So is handler what I am looking for or there’s a faster way?

    final Handler handler = new Handler();
    final Runnable runnable = new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            handler.post(new Runnable() {
                @Override
                public void run() {
                    infoMsg.setVisibility(View.INVISIBLE);
                }
            });
        }
    };
    new Thread(runnable).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-06-04T12:58:36+00:00Added an answer on June 4, 2026 at 12:58 pm

    handler is usually used for the UI thread in order to postpone something to be done in the future.
    in your example , this solution would be perfect.

    asynctask is used when you don’t care for when and what should be the order of the tasks to do . asynctasks should not be used for too long operations (like a connection that keeps being alive till the end user stops it) . you cannot assume that at more than one asynctask are active (but one is ok to assume) .

    for any other usage , i simply use a thread , but mostly the handler and the asynctask are enough.

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

Sidebar

Related Questions

I want to keep some of the critical(and less memory consuming) data of my
The .NET Framework allocates less memory for a Int32 than for a Int64 in
Which one is faster? Which one uses less memory? Console.WriteLine(string1) Console.WriteLine(string2) Console.WriteLine(string3) Console.WriteLine(stringNth) or
Is there a less brute-force way to do this? #!/bin/ksh THIS_SCRIPT=$(/usr/bin/readlink -f $(echo $0
DISCLAIMER: This question was not meant to be argumentative! What is fastest and less
Do const fields use less memory than regular variables?
What are some good tips for keeping memory usage low in a Perl script?
if i run a java program the VM initially allocates some memory for the
NFA advantages over a DFA: the representation uses less memory. NFA disadvantages compared to
What takes up less memory when allocating: UIView or UILabel? thanks

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.