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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:36:54+00:00 2026-05-17T01:36:54+00:00

First a little background. I got a warning in NetBeans told me not to

  • 0

First a little background. I got a warning in NetBeans told me not to start a new thread in a constructor. I have read that the reason for that is because the new thread might start and try to reference the object started the thread before the constructor is actually done making the object.

1.) For the sake of experimentation instead of using new Thread and thread.start() I tried ExecutorService and I got no warning. Does this mean it is ok to create and start a new thread in a constructor if I use ExecutorService?

2.) Also, if I have an ExecutorService in the form of a cached thread pool will the creation of a new thread by the standard method of new Thread and thread.start() pull a thread from the cache pool (or cause it to create one if one is not available) or are those threads completely independent of the cached thread pool?

  • 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-17T01:36:54+00:00Added an answer on May 17, 2026 at 1:36 am

    1) […] Does this mean it is ok to create and start a new thread in a constructor if I use ExecutorService?

    General rule: Don’t leak the reference to the object being constructed (this) until it is fully constructed. That is, don’t give away this to another therad in the constructor, don’t add yourself as a listener from within the constructor, etc, etc… That is, never use this as a parameter to a function from within the constructor.

    2) […] will the creation of a new thread by the standard method of new Thread and thread.start() pull a thread from the cache pool […]

    No, there is no way new could have been overloaded to not create a fresh object. In such cases you will need to go through a factory method.

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

Sidebar

Related Questions

First, a little background (greatly simplified): I have two classes, one called Entity and
First, a little background: I'm displaying a data set with 288 rows and 8
First a little background. I am building a mobile app for a client, this
First, a little background. Currently namespaces and assemblies in our codebase (~60 assemblies, thousands
A little background I'm working on an .net application that's uses plugins heavily, the
First a little intro: Last year i wrote this http://dragan.yourtree.org/code/canvas-3d-graph/ Now, i want to
First question on here so please be nice :) I know very little about
I know this question might sound a little cheesy but this is the first
OK, having tried my first TDD attempt, it's time to reflect a little and
First off, I am using Windows XP. I have multiple hard drives and it

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.