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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:10:37+00:00 2026-05-28T06:10:37+00:00

I am writing a servlet, which must start a thread in init() and correctly

  • 0

I am writing a servlet, which must start a thread in init() and correctly stop it after the server is stopped. Thread downloads a web page, parses it and stores data in MySQL database.

For stopping the thread I use servlet’s destroy() method. In this method I set condition for ending my thread. Is this the right way of doing it?

Can I see signs of the existence of my thread somewhere in my Windows? I didn’t find it in Windows Task Manager.

  • 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-28T06:10:37+00:00Added an answer on May 28, 2026 at 6:10 am

    The Windows task manager only shows processes, not individual threads. In fact, JVM-managed threads fall in the category of User threads, which is a distinct category from Kernel threads (managed by the operating system).

    To do what you want you will have to keep a global reference to your Thread object, such that it’s visible across different methods. It’s also preferable to make your thread spin on a flag and stop it by setting the flag, instead of using something like Thread.stop(). Something like this:

    class ThreadTask implements Runnable {
        private volatile boolean flag = false;
    
        public void setFlag(boolean value) {
            flag = value;
        }
    
        public void run() {
            while(!flag) {
               // execute code
            }
        }
    }
    

    And stop it by calling setFlag(true).

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

Sidebar

Related Questions

I am writing a servlet which will examine a directory on the server (external
I am writing a Java servlet, using Tomcat as the container, which creates and
I'm writing a servlet, which is executed in Java servlet container (eg, JBoss, Jetty,
I'm writing a servlet-based application in which I need to provide a messaging system.
I'm writing a Java servlet in Eclipse (to be hosted on Google App Engine)
I'm writing HTML code for a Java servlet. I first write the code in
Writing the code for the user authentication portion of a web site (including account
Writing a JSP page, what exactly does the <c:out> do? I've noticed that the
I'm writing a servlet that receives an xml file from the client and works
Good evening, I am in the process of writing a Java Servlet (Struts 2,

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.