| Back to Questions Page |
| |
| Question |
What are synchronized methods and synchronized statements? |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
| This Interview Question Asked @ Adobe |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Syncronized methods are executed only after a lock is
acheived on the classes or objects specified in the methids
and after that the methids are executed
Synchronized methods are executed after lock is acieved on
class or object specified in the synchronized statement  |
| Sainaveen |
| |
| |
| Question |
In howmany ways a thread can be created? |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
| This Interview Question Asked @ HCL |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | 1. Extending the Thread class
2. Implementing Runnable interface in a class and then
passing its reference to a new Thread.
3. Creating an anonymous class to extend the Thread class.
4. Creating an anonymous class to implement the Runnable
interface and then passing its reference to a new Thread.  |
| Ranganathkini |
| |
| |
| Answer | There are two different ways to create a Thread. One is
extends Thread class and implement Runnable Interface.
Better to go for Runnable interface. It will have a method
run(). You should override in the sub class. Even, you
can extend another class to the same thread class.  |
| Harish |
| |
| |
|
|
| |
| Question |
For an example, if we have some variable in run method, and
we created one or more threads. Does all threads will share
the same variable or a copy of variable is created for each
thread?? |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | No, each thread will have its own copy of the variable.
The reason is that run() is a method and any variable
declared inside a method is considered a local method and
its scope remains only within that method. If new thread
instances are spawned then each thread instances' run()
method will have their own copy of the variable.  |
| Ranganathkini |
| |
| |
| Question |
What is the use of Semaphore? |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Semaphore variable are to make sure that some shared
variable is not being modified/updated simultaneously by
two separate processes/threads.  |
| Geeta |
| |
| |
| Answer | It is being used to prevent DEADLOCK upto some extent only.
It is a primitive level mechanism.  |
| Anonymous |
| |
| |
| Answer | Semaphore is to solve the problem of syncronisation. It is
a monitor, to monitor the critical section of the program.
it can be implemented with the help of the a single
variable and depending upon the value of that variable
thread is allowed to enter in the critical section.  |
| Rajesh |
| |
| |
| Question |
JMS based on what technology? |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | JMS is based on Java technology it used for messaging
between different applications.JMS provides asynchronous
messaging.  |
| Sainaveen |
| |
| |
| Question |
Is 'synchronised' a modifier? |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | no synchronised is not a modifier
it is a key word which can do a specific functionality on
thread.  |
| Satya |
| |
| |
|
| |
|
Back to Questions Page |