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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:28:22+00:00 2026-05-13T23:28:22+00:00

Lets assume following classes definition: public class A { public final static String SOME_VALUE;

  • 0

Lets assume following classes definition:

public class A {
    public final static String SOME_VALUE;

    static {
        SOME_VALUE = "some.value";
    }
}

public class B {
    private final String value = A.SOME_VALUE;
}

Assuming that the class A hasn’t been loaded yet, what does happen when object of the class B is instantiated by some thread T? The class A has to be loaded and instantiated first. But my question is: if it’s done in context of the thread T, or rather in context of some other (special) “classloader” thread?

  • 1 1 Answer
  • 1 View
  • 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-13T23:28:23+00:00Added an answer on May 13, 2026 at 11:28 pm

    There is no special thread for loading classes. It will be from the thread which refers to the class for the first time. The ClassLoader.loadClass method is synchronized so that multiple threads trying to load the same class don’t interfere.

    EDIT Code to enumerate

    public class Arbit {
        public static void main(String[] args) throws Exception{
            B b1 = new B("1");
            B b2 = new B("2");
            B b3 = new B("3");
            b1.start();
            b2.start();
            b3.start();
            b1.join();
            b2.join();
            b3.join();
        }
    }
    
    class B extends Thread{
        B(String s){
            setName(s);
        }
        @Override
        public void run() {
    
            try {
                Thread.sleep(new Random().nextInt(100));
            } catch (InterruptedException e) {
            }
            System.out.println(A.s);
        }
    }
    
    class A{
        static String s = Thread.currentThread().getName();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's assume I have the following code: public class MainClass { public static void
Lets assume I have the following Java code: public String foo() { // returns
Let's assume the following method (say from Guava's Iterables): public static <T> Iterable<T> filter(final
Lets assume we have the following code: abstract class Base1 { protected int num;
Background: Let's assume I've got the following class: class Wrapped<T> : IDisposable { public
Lets assume I had the following Model class A(Models.model): def __init__(self,data): B(a=self,data=data).save() class B(Models.model):
Lets assume the following: string s(!Hello!'); My aim is to obtain in the s
Lets assume i have a dataview with the following itemTpl itemTpl: [ '<div class=category_entry_inner>',
assume the following class is given: class Base{ public: Base() {} Base( const Base&
Lets assume the following string is entered into a form and submitted to a

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.