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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:54:32+00:00 2026-06-08T16:54:32+00:00

I have a program using a thread. When my program is closed, my thread

  • 0

I have a program using a thread. When my program is closed, my thread is still running and that’s normal. I would like to know how my thread can detect that the main program is terminated; by itself ONLY. How would I do that?

My thread is in an infinite loop and process many object in a Queue. I can’t define my thread as a daemon, else I can lose some data at the end of the main program. I don’t want that my main program set a boolean value when it closed.

  • 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-08T16:54:35+00:00Added an answer on June 8, 2026 at 4:54 pm

    If you can get a handle to the main thread, you can call is_alive() on it.

    Alternatively, you can call threading.enumerate() to get a list of all currently living threads, and check to see if the main thread is in there.

    Or if even that is impossible, then you might be able to check to see if the child thread is the only remaining non-daemon thread.

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

Sidebar

Related Questions

I have a c# program using WPF. I have it that when you press
I have a program that draws some vector graphics using System.Drawing and the Graphics
I have 2 applications communicating using named pipes. Main program calls client program and
I have a BluetoothSocket that I am reading data from, using a separate Thread
I have a Visual C++ program that opens a file in one thread with
I have a GUI program that, in this example, downloads an exe using wget
I have a main thread and a separate thread in my program. If the
I have a program using odac(11.2) and oracle client 11.2. Now I want to
I have a program in C using Solaris with VERY ancient compatibility it seems.
I have the following MonoTouch program: using System.Drawing; using MonoTouch.Foundation; using MonoTouch.UIKit; using System;

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.