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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:48:45+00:00 2026-05-23T12:48:45+00:00

For thread-safety reasons it is argumented: Do not allow the this reference to escape

  • 0

For thread-safety reasons it is argumented:

Do not allow the this reference to escape during construction.

But is this always an issue and should be avoided by using newInstance() methods? Inside my model class I have a TableModel which should be instantiated, within the model class, but which also requires a reference to the model class:

public class MainModel {

   TableModel tableMode;

   public MainModel() {
      tableModel = new MyTableModel(this);
   }
}

If the constructor does not use this right away is it then safe or should it be avoided in any means?

  • 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-23T12:48:45+00:00Added an answer on May 23, 2026 at 12:48 pm

    If nothing in the MyTableModel is going to do anything in other threads etc – or copy the variable to some other shared data, such as a static variable – then it’s safe.

    Of course, if MyTableModel starts calling methods on the MainModel reference within its constructor, then it’ll be calling them on a not-completely-initialized-yet object, which can cause issues – but that’s not really threading related.

    I blogged a bit more on this a while ago.

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

Sidebar

Related Questions

This is about thread safety of std::map . Now, simultaneous reads are thread-safe but
I have a method that for thread-safety reasons should only ever be used by
I'm trying to use ThreadLocal to provide thread safety to pre-existing non-thread-safe classes, but
In many MSDN documents, this is written under the Thread Safety heading; Any public
I've just started learning about thread safety. This is making me code a lot
Is there anything wrong with the thread safety of this java code? Threads 1-10
When should I use volatile/Thread.MemoryBarrier() for thread safety?
This question is a follow up to the C# Events and Thread Safety question
From this article http://www.stuartellis.eu/articles/erb referring to thread safety levels: At this level, the specified
This may be seen as a duplicate of Thread safety, lists, binding and WPF

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.