1.IF IS IT TRUE TO SAY THAT MORE THAN ONE THREAD HAS THE SAME NAMES THAN IN THAT CASE HOW TO IDENTIFY THE THREADS WITH SIMILAR NAMES?
2.public class TwoThreadsDemo1 { public static void main (String[] args) { new Thread("Jamaica").start(); new Thread("Fiji").start(); } } IN THE ABOVE PROGRAM WHICH THREAD WILL START ITS EXECUTION?HOW THE PROCESS GOES ON?
3.WHTS THE PRORITY SET WHEN A THREAD IS BEING CREATED AND WHTS THE DEFAULT PRIORITY?
4.objects having locks and wait sets are referred to as monitors?what actually are the monitors
Tnanks venkatramsimha
Alex Belisle Turcot
Ranch Hand
Joined: Apr 26, 2005
Posts: 516
posted
0
Hi,
well if you set the same name for 2 threads, the method getName() will return the same String. Maybe you can define your own status inside the thread, use something else than the name to identify them...
The start() method starts a new thread and execute the run() method. Since you do not override the run() method in your thread declaration, the default Thread.run() is executed and does nothing.
try this instead...
By default, threads are set to priority 5, out of 10, which is "normal". static constant are accessible in Thread
Also, you can use the static method Thread.currentThread() to get a reference to the current thread object. This can be usefull to verify in which thread you are currently...
Below some details on the monitors, found on the web
Thread Synchronization Problems may occur when two threads are trying to access/modify the same object. To prevent such problems, Java uses monitors and the synchronized keyword to control access to an object by a thread. Monitor
Monitor is any class with synchronized code in it. Monitor controls its client threads using, wait() and notify() ( or notifyAll() ) methods. wait() and notify() methods must be called in synchronized code. Monitor asks client threads to wait if it is unavailable. Normally a call to wait() is placed in while loop. The condition of while loop generally tests the availability of monitor. After waiting, thread resumes execution from the point it left.