Hi Friends, I am new to java. Can u explain about thread
concept.How i know one thread is locked, and how can i force
or acquire another thread for lock . Finally how to know
thread is released from lock. Explain types of lock(like
method level and block level) in thread.
Answer / ravikiran
Thread is a sequential flow of control
With the help of wait(),notify(),notifyAll() methods from
the Object class
We can force a thread to be locked by making the object to
be synchronized or putting the code inside a synchronized block
We will got to know the unlocking status with the help of
notify / notifyAll method calls.
Method level block will provide a lock for the whole method
access.Block level lock will lead to a particular portion of
a program to be get locked.
| Is This Answer Correct ? | 2 Yes | 0 No |
What is a parameter in matrices?
How do you declare an array that will hold more than 64KB of data?
Given: 10. interface A { void x(); } 11. class B implements A { public void x() { } public voidy() { } } 12. class C extends B { public void x() {} } And: 20. java.util.List list = new java.util.ArrayList(); 21. list.add(new B()); 22. list.add(new C()); 23. for (A a:list) { 24. a.x(); 25. a.y();; 26. } What is the result? 1 Compilation fails because of an error in line 25. 2 The code runs with no output. 3 An exception is thrown at runtime. 4 Compilation fails because of an error in line 20.
when to use abstract class and when to use interface?
16 Answers Exterro, iGate, IonIdea,
How to handle a web browser resize operation?
What is compile time polymorphism?
20 Answers CTS, Elementus Technologies, Oracle,
what is the main difference between string and stringbuffer? can you explain it with program?
What is a class variable?
Can we start a thread twice in java?
In the below Java Program, how many objects are eligible for garbage collection?
Is ResultSet class?
5 Answers Bally Technologies, TCS,
Explain about varargs in java?