Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From the Javadoc of <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html" rel="nofollow">Thread</a>:</p> <blockquote> <p>A thread is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution running concurrently.</p> <p>Every thread has a priority. Threads with higher priority are executed in preference to threads with lower priority. Each thread may or may not also be marked as a daemon. When code running in some thread creates a new Thread object, the new thread has its priority initially set equal to the priority of the creating thread, and is a daemon thread if and only if the creating thread is a daemon.</p> <p>When a Java Virtual Machine starts up, there is usually a single non-daemon thread (which typically calls the method named main of some designated class). The Java Virtual Machine continues to execute threads until either of the following occurs:</p> </blockquote> <ol> <li>The exit method of class Runtime has been called and the security manager has permitted the exit operation to take place.</li> <li>All threads that are not daemon threads have died, either by returning from the call to the run method or by throwing an exception that propagates beyond the run method. </li> </ol> <p>Now, to your questions.</p> <ul> <li><strong>When [is a] new stack is created? On executing Thread t=new Thread() or t.start()?</strong></li> </ul> <p>A new thread is created by the constructor. It is run with the start method.</p> <ul> <li><strong>How [does] start() method calls implemented run()?</strong></li> </ul> <p>From the source code of <a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/Thread.java" rel="nofollow">Thread</a>:</p> <pre><code>public void run() { if (target != null) { target.run(); } } </code></pre> <ul> <li><strong>Can we assign memory to each thread like JVM? If No, how JVM will modify stack memory of running thread.</strong></li> </ul> <p>No, you cannot assign memory to each thread. The operating system (Windows, Unix, OS X) controls how threads are created and destroyed. The JVM has access to every thread through a string identifier.</p> <p>You can read the <a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/Thread.java" rel="nofollow">Thread source code</a> for more information about the Thread class.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload