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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:24:51+00:00 2026-05-25T10:24:51+00:00

Thread number (id) increments when thread is terminated and a new thread created. Does

  • 0

Thread number (id) increments when thread is terminated and a new thread created. Does Java 7 just enjoy incrementing numbers or am I doing something wrong?

I’m building a service application using Java 7 that creates a new thread when a connection is made and then services the connection. When the service receives a close message, it drops out of a loop and allows completion of the code in the thread. Thus, the thread’s life is supposedly terminated, as I understand it (just like any instance object). Java 7 doesn’t use a Thread.stop() or Thread.destroy() or any such thing. (Not since v5 I think.)

I have an interface with buttons for “Open Connection”, “Close Connection”, and “Send Message” and corresponding println statements in the thread so I can see what’s happening. One of the variables I print out is Thread.currentThread(). When I open the first connection, the currentThread() is Thread[Thread-0,5,main]. I close the connection and get the message out of loop indicating that Thread[Thread-0,5,main] is terminating.

OK, so now it’s back to square one, right? No threads.

I click to connect again and and enter Thread[Thread-1,5,main]. See that? “Thread-1” instead of “Thread-0”. Each time I do it, the number goes up by 1.

(Side question if it’s not too much trouble. What’s the “5,main” mean?)

Commentary re: thread stop: Why are Thread.stop, Thread.suspend and Thread.resume Deprecated?.

  • 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-25T10:24:52+00:00Added an answer on May 25, 2026 at 10:24 am

    Thread-0,5,main

    0 : id

    5 : priority

    main : name

    thread id is long; if we create a million threads a second, after 300 thousand years, id will overflow.

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

Sidebar

Related Questions

how many number of thread per process default in the system.thread.threadpool in asp.net 3.5
I've seen a number of examples that have a thread procedure that looks like
I'd like to log the number of active threads created by a newCachedThreadPool call.
I am new to multithreading, and I wrote this code which prints the numbers
I need to generate an unique number of 32 bits in Java. I need
When I write the below code, why do I get avaliable Thread number like
As someone new to GUI development in Python (with pyGTK), I've just started learning
What is the maximum number of threads you can create in a C# application?
I have an object for which I'd like to track the number of threads
In former versions of Parallel Extensions you could set the number of threads: enumerable.AsParallel(numberOfThreads)

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.