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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:39:27+00:00 2026-06-03T00:39:27+00:00

I just made a countdown app with three threads including the main thread. I

  • 0

I just made a countdown app with three threads including the main thread. I have CountdownEven set to low so that countdownOdd will display first but in the output nothing is happening. Can anyone see the problem?

//Main
public class CountdownApp 
{

    public static void main(String[] args) 
    {
    new CountdownApp().start();

    }
    public void start()
    {
        Thread count1 = new CountdownEven();
        Thread count2 = new CountdownOdd();
        count1.setPriority(Thread.MIN_PRIORITY);
        count2.setPriority(Thread.MAX_PRIORITY);
        count1.start();
        count2.start();
    }

}


public class CountdownEven extends Thread
{
    public void run()
    {
        for(int i = 10; i > 0; i-=2)
        {
            System.out.println(this.getName()+ " Count: " +i);
            Thread.yield();//This is to allow the other thread to run.
    }
    }


}

public class CountdownOdd extends Thread
{
    public void run()
    {
        for(int i = 9; i > 0; i-=2)
        {
            System.out.println(this.getName()+ " Count: " +i);
            Thread.yield();//This is to allow the other thread to run.
    }
    }

}
  • 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-03T00:39:28+00:00Added an answer on June 3, 2026 at 12:39 am

    I tried your code and it does produce an output.

    Thread-0 Count: 10
    Thread-0 Count: 8
    Thread-0 Count: 6
    Thread-0 Count: 4
    Thread-0 Count: 2
    Thread-1 Count: 9
    Thread-1 Count: 7
    Thread-1 Count: 5
    Thread-1 Count: 3
    Thread-1 Count: 1
    

    Exactly the output as it should be… so whats your prob?
    Maybe you just have to open a new console widget/tab in eclipse or you have any active filter?

    But imho I wont use Threadpriorities for this purpose, see
    http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Thread.html

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

Sidebar

Related Questions

I have just made my first proper little desktop GUI application that basically wraps
I just made my first jQuery mobile site. I want to have people that
I have a silly little game that I made just for myself, but I
I have just made an app for Android phones. It is a rather simple
I have just made an app and now I'm planning to make a 'pro'
I have just made a small little app of a Python wxPython script with
I have just made my app universal by combining separate iPhone and iPad projects.
I was just made aware of a bug I introduced, the thing that surprised
I have just made a portlet with web service for liferay to learn how
I have an image which is just made of one color ? (it could

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.