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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:12:41+00:00 2026-06-12T16:12:41+00:00

I am running multiple thread and Handler in my code. And this is my

  • 0

I am running multiple thread and Handler in my code.

And this is my Handler

PrizeRunnable mTempPotionRunnable = new PrizeRunnable(aaa);
handler.postDelayed(mTempPotionRunnable, 4000);

and

        class PrizeRunnable implements Runnable {
        String type;

        PrizeRunnable(String type) { 
            this.type = type; 
        }

        public void run() {
            synchronized (this) {
                  if(!mIsHandlerStarted){
                      if(type.equals(aaa))
                          // Do something
                      else if(type.equals(bbb))
                          // Do something

                    mIsHandlerStarted = true;
                    handler.removeCallbacks(this);
                  }
              }
        }
    }

But sometime it run simultaneously.

i don not know the reason.

UPDATED

I try to change it to:

handler.postDelayed(mTempPotionRunnable, 4000);

and

Runnable mTempPotionRunnable = new Runnable() {
@Override
public void run() {
      synchronized (this) {
          if(!mIsHandlerStarted){
                // Do something
                mIsHandlerStarted = true;
                handler.removeCallbacks(mMetalRunnable);
          }
      }
}
};

May be it resolve my problems. I am testing this method.

But i can’t pass parameter to my Runnable . How can i do it?

  • 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-12T16:12:42+00:00Added an answer on June 12, 2026 at 4:12 pm

    Make global variable and i can pass parameter to my Runnable

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

Sidebar

Related Questions

We are running multiple domains through the same code and we want to save
I am running this program where I have multiple threads. Three threads are generating
Does running multiple Solr shards on a single machine improve performance? I would expect
Curious about running multiple xvfb displays: I have between 10-50 instances of a script
We're looking into running multiple instances of Tomcat from the same copy of the
Currently we are running multiple Sitecore projects. Whenever the projects go live we create
I am running multiple screens from one ssh connection, when I list all of
Background: I'm running multiple simulations on a set of data. For each session, I'm
I am running multiple reports and combining them into a single PDF file. For
Any one have an idea to share running multiple tomcats on single machine with

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.