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.
I have to create a progress bar in a webapp. I need a thread
Share
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
InitializingBeanto start the thread, and you can inject the bean into other classes so they could call getters onvolatileorsynchronizedfields. Something like: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.