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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:55:49+00:00 2026-05-27T17:55:49+00:00

I have a java program which emulates a car fabric. I wrote an explanation,

  • 0

I have a java program which emulates a car fabric. I wrote an explanation, but it would be pretty hard to understand and not really useful, so I’ll just ask the “abstract” question.

I have an infinite loop which calls the method “now” wich tells the fabric to build a new car.

    while(true){
        try{
            Thread.sleep(500);
        }catch (Exception e) {;}
        fabric.now();
    }

Inside the fabric there are 3 zones; stage 0 where the body of the car is created, stage 1 where the car is provided with lights, stage 2 where I put a bumper on it and finished which is the place where all finished cars are placed.

When the menthod now is called for the very first time, it creates the body of the car in the stage 0. Then, when it’s called for the 2nd time, it moves the first body to stage 1, it puts the lights of the car (by drawing two circles) and it creates a new body. It goes on this way until the car is ready, which is when it’s moved to the finished zone.

Here is my problem. The 2nd time I call the now method, it does 3 things:

i. it paints a car-body in the 1 stage
ii. it paints a new car-body in the 0 stage
iii. it paints the lights over the car-body on the 1 stage.

I want to delay the step (iii) so people can see the car being provided with lights. If I use wait, thread.sleep, or do a cycle wich takes x milliseconds, it delays the whole fabric from then on.
I think what I need is to take the (iii) step out of the normal flow and do it separately, so when I wait 350 milliseconds before painting the lights it doesn’t delay the rest of the fabrication-process. (the rest of the painting).

Any ideas?

  • 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-27T17:55:50+00:00Added an answer on May 27, 2026 at 5:55 pm

    Here is my assumption about your question:
    you want to call now() method at regular interval of say 500ms. Now irrespective of the you want to delay the subtask 3 inside the now(). This also means the delay in subtask 3 should not delay the call to now() at every 500ms

    If this is your requirement then I suggest you using java.util.Timer.scheduleAtFixedRate

    Simply create a TimerTask and wrap your now() call inside it.

    Use wait(500) or how much ever you want in subtask 3.

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

Sidebar

Related Questions

I currently have a small Java program which I would like to run both
I have a program which i have myself written in java, but I want
I have a Java program, in which, I'm using a JTextField, but if i
I have a Java program using AWT which I would like to run on
I have a Java program in which an action is initiated which loops through
I now have a running Java program which only lacks of the final step,that
How to write a java program which will tell me whether I have internet
I have two strings in a java program, which I want to mix in
We have a Perl program to validate XML which is invoked from a Java
I have a Java program that loads thirdparty class files (classes I did not

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.