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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:13:54+00:00 2026-06-13T11:13:54+00:00

I have following code. public class SplashScreen extends Activity { private int _splashTime =

  • 0

I have following code.

public class SplashScreen extends Activity {
    private int _splashTime = 5000;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                 WindowManager.LayoutParams.FLAG_FULLSCREEN);

        new Handler().postDelayed(new Thread(){
           @Override
           public void run(){
             Intent mainMenu = new Intent(SplashScreen.this, MainMenu.class);
             SplashScreen.this.startActivity(mainMenu);
             SplashScreen.this.finish();
             overridePendingTransition(R.drawable.fadein, R.drawable.fadeout);
           }
        }, _splashTime);
    }
}

I have problem in analyze of this code. As far as know handler is running in main thread. but it has thread which is running in other thread.

MainMenu.class will be run in main thread or second thread?
if main thread is stopped for 5 seconds ANR will be raise. Why when I am stopping it with delay (_splashTime) ANR doesn’t display (even if i increase it to more than 5 seconds)

  • 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-13T11:13:55+00:00Added an answer on June 13, 2026 at 11:13 am

    As far as know handler is running in main thread.

    Objects do not run on threads, because objects do not run. Methods run.

    but it has thread which is running in other thread.

    You have not posted any code which involves any “other thread”. Everything in the code listing above is tied to the main application thread of your process.

    MainMenu.class will be run in main thread or second thread?

    Objects do not run on threads, because objects do not run. Methods run. MainMenu appears to be an Activity. The activity lifecycle methods (e.g., onCreate()) are called on the main application thread.

    Why when I am stopping it with delay (_splashTime) ANR doesn’t display (even if i increase it to more than 5 seconds)

    You are not “stopping [the main application thread] with delay”. You have scheduled a Runnable to be run on the main application thread after a delay _splashTime milliseconds. However, postDelayed() is not a blocking call. It simply puts an event on the event queue that will not be executed for _splashTime milliseconds.

    Also, please replace Thread with Runnable, since postDelayed() does not use Thread. Your code compiles and runs, because Thread implements Runnable, but you will confuse yourself by thinking that using Thread instead of Runnable means that your code will run on a background thread, and it will not.

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

Sidebar

Related Questions

I have following code: public class readSensorsData extends Activity implements SensorListener { /** Called
I have the following code: public class SplashScreenActivity extends Activity { private boolean animated
I have the following code: public class Test extends JFrame implements ActionListener{ private static
I have the following code: public class TestSynch extends Activity { public static ArrayList<HashMap<String,String>>
I have following code: public class ShowActivity extends ListActivity implements OnItemClickListener { /** Called
I have the following code :- public class Test5 { private int value ;
I have following code: public class reader extends Activity { WebView mWebView; String mFilename;
I have the following code: public class Events extends ListActivity { //... private static
I have the following layout : And following code : public class MailSenderActivity extends
Lets say that I have the following code: public class Shelter<A extends Animal, B

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.