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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:16:10+00:00 2026-06-07T22:16:10+00:00

I need to create a thread that listens to a filepath for new, modified

  • 0

I need to create a thread that listens to a filepath for new, modified or removed files. I am using a web application that uses Spring 3, Struts 2 and Hibernate 3. If I run the project, it loads the index.jsp which contains the text “Hello World”.

The problem is that when I create a java Thread() that listens to the filepath and assign it to index.jsp:

<action name="" method="runThread" class="TestThreadBean">
     <result>index.jsp</result>
</action>

Then “Hello World” text does not ever appear because the Thread doesn’t ever stop (Which is right, it’s not supposed to stop). I need this Thread to be running in the background and not interfere with the rest of the web application. I don’t want to create a separate web application just for this Thread though. Also, I don’t want a new Thread instance to be created each time a new Session instance is created, there should be just one Thread instance no matter how many Session instances there are active.

  • 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-07T22:16:12+00:00Added an answer on June 7, 2026 at 10:16 pm

    Basically, people will suggest not to start your own thread in a container managed application, like a web application or an enterprise (EJB) application.

    This is because in a container environment all the resources including threads should be managed by container. But IMHO if you know the implications, and the life cycle of our own thread and its resources, like wrapping this thread with a transaction etc, then we can create a thread by using the standard way (new Thread()), but it is just my opinion.

    I would suggest you to go through the ‘Container managed threads’ once before you make a decision. You can refer commonJ once to get a handle to Container’s thread pool, but as this is not a standard or not mentioned in the container specifications, It may not work for all the containers. This will work for:

    • Weblogic
    • Websphere
    • Tomcat, Jboss and may be for others
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that uses Struts2 + Spring for the resource injection,
I need to create async thread that runs once with a delay of 2
I need to create a server which creates a new thread for each client
Inside first thread I need to create another thread. Thread thread2 = new Thread(bworker);
I need to obtain the Thread Id from a window create in runtime with
I have to create a progress bar in a webapp. I need a thread
I want to create a thread for some db writes that should not block
I am trying to create a thread to handle a login function that is
A have ASP.NET 2.0 web application that should allow sending emails. I have a
Ok, here is my problem. I need to create a socket program that can

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.