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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:54:37+00:00 2026-05-23T12:54:37+00:00

package com.aviyehuda.test.multithreading; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.view.View; import android.widget.Button; import android.widget.TextView;

  • 0
package com.aviyehuda.test.multithreading;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MultithreadingTest extends Activity {
Button btn;
private Handler myHandler;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    btn = (Button) findViewById(R.id.Button01);
}

public void buttonClicked(View v) {
    myHandler = new Handler();
    MyThread mThread = new MyThread();
    mThread.start();
}

class MyThread extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 30; i++) {
            myHandler.post(new NewThreaad(i));
        }
    }
}
class NewThreaad implements Runnable{
    int i;
    public NewThreaad(int n) {
        i=n;
    }
        @Override
        public void run() {
            ((TextView) findViewById(R.id.TextView01)).setText("Hello:"+i);
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
}
}

I have code mentioned above but getting result Hello29 on TextView but i want Hello1,Hello2,hello3……………..Hello29 one by one automatically

Please give me hint what I am doing wrong

  • 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-23T12:54:37+00:00Added an answer on May 23, 2026 at 12:54 pm

    You need to move the 500 ms delay to your for-loop, between posting of messages. I think you’re expecting the messages to execute sequentially one after the other, but they don’t, which is the reason you just see the result of the last one.

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

Sidebar

Related Questions

Let's say I have a file called test.txt within the package com.test.io within my
package com.services { import com.asfusion.mate.events.ResponseEvent; import com.events.navigation.DesgManagementEvent import flash.events.EventDispatcher; import mx.controls.Alert; public class UserManager
package com.test; public class OuterClass { public class InnerClass { public class InnerInnerClass {
package com.adam.etutorial { import flash.display.MovieClip; import flash.text.TextField; import flash.display.Sprite; import flash.text.TextFormat; import flash.display.Shape; public
SampleBean: package com.springexample; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; public class SampleBean { private BeanTypeOne beanOne;
1) Bundle A reexports package com.X, which it gets from bundle C 2) Bundle
02-18 00:02:08.432: ERROR/PackageManager(57): Package com.example.brown requires unavailable shared library com.google.android.maps; failing! I got this
Given a property: <property name=classes value=com.package.Class1,com.package.Class2 /> I'm trying to compile only the classes
Please consider the following java source: package com.stackoverflow; public class CondSpeed { private static
I have a EJB defined as this: package com.foo; @Stateless (mappedName=HelloWorld) public class HelloWorldBean

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.