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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:58:44+00:00 2026-05-26T04:58:44+00:00

I hava some code like this: class LooperThread extends Thread { public Handler mHandler;

  • 0

I hava some code like this:

class LooperThread extends Thread {
    public Handler mHandler;

    public void run() {
        Looper.prepare();

        mHandler = new Handler() {
            public void handleMessage(Message msg) {
                  // process incoming messages here
            }
        };

        Looper.loop();
    }
}

I want to know which thread the “mHandler” belong to?

Add: Is it different if I declare(or instance it) in different thread.

  • 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-26T04:58:44+00:00Added an answer on May 26, 2026 at 4:58 am

    It doesn’t belong to any thread. It is public so any thread can access it and modify. That being said it is crucial to make it thread safe (your code isn’t – the variable isn’t volatile).

    The bottom line is – every object created using new operator is placed on the heap which is shared among all the threads. Other threads can access the object reference e.g. if it is not encapsulated like in your example or exposed on purpose.

    Technically speaking – in Java any object does not belong to any other – all references to a given object are equal. And when the last reference to the object (huge oversimplification) are gone, it is garbage collected. So one can say: the last reference owns the object.

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

Sidebar

Related Questions

hi i hav a code like this in the end i m getting error
Here's the thing. I hava a simple snippet in PHP like this regarding a
I hava a java program, a section of it is compute intensive, like this
I hava a remote validator setup like so remote: { type: POST, url: /some/url,
I hava a thread in which I have an infinite loop, doing some network
i have some small problem. I hava some class Processor and Process . Process
I hava a CSV file that I want to treat as source code. Essentially
I hava a data window object, in which I am fetching some attributes from
i hav a file with some data and i want to attach this file
I hava a xml doc (and complex element) that is similar to this example:

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.