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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:47:05+00:00 2026-06-07T00:47:05+00:00

I have to create a progress bar in a webapp. I need a thread

  • 0

I have to create a progress bar in a webapp. I need a thread that do the work and a controller that tests this thread to get his status.
How to set it using beans (inside that thread I need to autowire some services)? Can I use thread as non-singleton bean?
Thank you.

  • 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-07T00:47:06+00:00Added an answer on June 7, 2026 at 12:47 am

    I’d create a small wrapping class for this. You could have all of your setters in the class to handle the injected services, you could use InitializingBean to start the thread, and you can inject the bean into other classes so they could call getters on volatile or synchronized fields. Something like:

    public class ProgressBar implements InitializingBean, Runnable, DisposableBean {
        private volatile int someField;
        private Thread thread;
        // start the thread after the properties are set
        public void afterPropertiesSet() {
            thread = new Thread(this);
            // maybe make it a daemon thread
            // thread.setDaemon(true);
            thread.start();
        }
        // stop it when spring is shutting down
        public void destroy() {
            thread.interrupt();
        }
        public void run() {
           ... thread code goes here
        }
        // spring setter
        public void setSomeService(SomeService someService) {
           this.someService = someService;
        }
        // getter used by other beans to get some value from this class
        public int getSomeField() {
            return someField;
        }
    }
    

    You could also use some of spring’s timer classes for this of course although they work better for repetitive tasks that run every so often.

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

Sidebar

Related Questions

I'm trying to create a progress bar that will work asynchronously to the main
I have this progress bar that uses callback functions from a third party driver,
I am trying to create a thread that contains a form progress bar (just
I have a progress bar which I create in code my activity. This is
I have create a vcf file that contains contacts by using this code ContentResolver
I have create name range on sheet A so I need to use this
I want to create loading progress bar when my activity is starting. I have
I'm planning to create a custom progress bar control, that supports progress sectioning. The
Possible Duplicate: Jquery:: Ajax powered progress bar? I need to create some kind of
I used this tutorial http://delphi.about.com/od/kbthread/a/thread-gui.htm to create a class that asynchronously downloads a file

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.