Wednesday, May 24, 2006

Basics of Thread

1). Threads operate on their on own copies of instance variables.
2). In synchronized methods wait() causes the thread to give up the monitor.
3). If the reference to the thread is set to null, thread doesn't stops executing.
4). In synchronized methods yield() and sleep() doesn't causes the thread to give up the monitor.

Monday, May 22, 2006

Thread eligible to run

When a new Thread class is instantiated and its start method is called, system resources required for the thread are allocated. The thread is made eligible to run and must content with other threads for the CPU. When the scheduler decides to move it to the running state the run method is then executed.

Priority from Parent Thread to Child Thread

The default priority when a Thread is created is 5. When a Thread is created from within a Thread, the priority will be passed on from parent to child.

Thread.yield()

The yield method provides a hint to the JVM that if there are other runnable threads, the scheduler should run one instead of the current thread. The JVM may interpret this hint in any way it likes - that is how the yield is handled is dependent on the JVM implementation for the operating system.