Re: one thread is created for each object construction?
Lew wrote:
Ishwor Gurung wrote:
Loosing some foundation here... Internally in the JVM, how is the object "e"
represented? It'll well be an instance of a class in the heap but that's
not what I intended to ask. Apologies. What I wanted to ask (without
forking a seperate discussion thread :-) was how threading works at JVM
level.
Threading works by spawning a new OS thread and executing code in that thread.
The object "e" is represented by a data structure on the heap. It has nothing
to do with threading. There is bytecode at a location in the JVM that
represents the data and methods of the object.
Yes, java will look like any other process to the OS. But how are different
_instances_ of different non-related class represented in JVM? This seems
to point me to the assumption, that the classes are indeed executing as
threads in JVM.
They aren't. Different instances are represented as separate collections of
data on the heap.
The OP had asked if constructing an object spawned a new thread. It does
not.
Yes, but how about in the JVM? Is there a tutorial on how JVM works
somewhere? Perhaps tucked neatly instead of Sun's
lengthy-full-of-mathematical-symbol ones? :P
I don't understand what you're asking, really. Construction of an object does
not spawn a new thread, not in the JVM, not anywhere, not nohow. (Of course,
it is possible that someone somewhere might write a JVM that violates this,
but it doesn't change the conceptual model. Anyhow, no JVM I've heard of does
violate this.)
Threads and construction are orthogonal concepts.
I don't know about tutorials about specific JVM implementations. There are
several JVMs out there. The JLS defines precisely how it must behave, though.
I really think I am not understanding your question. I am confused by how
people keep talking about constructors and threads in the same breath. What
are you actually asking?
--
Lew