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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:30:21+00:00 2026-05-25T09:30:21+00:00

I am not understanding this concept in any manner. public class SomeName { public

  • 0

I am not understanding this concept in any manner.

public class SomeName {

     public static void main(String args[]) {

     }

}

This is my class SomeName. Now what is thread here.

  1. Do we call the class as a thread.
  2. Do we call this class as thread when some other object is trying to access its method or members?
  3. Do we call this class as thread when some other object is trying to access this object?
  4. What does it mean when we call something in java as thread-safe ?
  • 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-25T09:30:21+00:00Added an answer on May 25, 2026 at 9:30 am

    Being thread-safe means avoiding several problems. The most common and probably the worst is called threadlock. The old analogy is the story of the dining philosophers. They are very polite and will never reach out their chopsticks to take food when someone else is doing the same. If they all reach out at the same time, then they all stop at the same time, and wait…and nothing ever happens, because they’re all too polite to go first.

    As someone else pointed out, if your app never creates additional threads, but merely runs from a main method, then there is only one thread, or one “dining philosopher,” so threadlock can’t occur. When you have multiple threads, the simplest way to avoid threadlock is to use a “monitor”, which is just an object that’s set aside. In effect, your methods have to obtain a “lock” on this monitor before accessing threads, so there are no collisions. However, you can still have threadlock, because there might be two objects trying to access two different threads, each with its own monitor. Object A has to wait for Object B to release its lock on monitor object 1; Object B has to wait for Object A to release its lock on monitor object 2. So now you’re back to threadlock.

    In short, thread safety is not terribly difficult to understand, but it does take time, practice and experience. The first time you write a multi-threaded app, you will run into threadlock. Then you will learn, and it soon becomes pretty intuitive. The biggest caveat is that you need to keep the multi-threaded parts of an app as simple as possible. If you have lots of threads, with lots of monitors and locks, it becomes exponentially more difficult to ensure that your dining philosophers never freeze.

    The Java tutorial goes over threading extremely well; it was the only resource I ever needed.

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

Sidebar

Related Questions

I am really stuck on this. I'm clearly not understanding the MIN/MAX concept. I
I'm not quite understanding how this works. Passing parameters from my entity objects works
I've read this answer about eight-five times, but there's something I'm not understanding correctly:
I've been reading a bit on the singleton concept. While not fully understanding it,
I'd like to extract a date from any string entered. But not specific to
Not understanding why my commit to remote git repo is not working. So I
Im not understanding something about rest web services. When you do get, post etc
I'm not understanding how OAuth2 works for Google API. Supposing I've signed in API's
I have some not understanding actions from gnu clisp Suppose, I have some code
I am not understanding the 'aligning allocated memory' part from the mprotect usage. I

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.