Lal Mothi

Greenhorn
+ Follow
since Nov 03, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Lal Mothi

What is the basic difference between the 2 approaches to exception handling.
1> try catch block and
2> specifying the candidate exceptions in the throws clause?
When should you use which approach?
[ November 15, 2007: Message edited by: Lal Mothi ]
16 years ago
Can Any one help in this regard. when a user hits server. how can we know that a request is came from servelet or jsp?
16 years ago
Catch (Exception e),
Catch (Error err),

Catch (Throwable t)
16 years ago
First of all to achieve Multithreading mechanism in java we should go for synchronization. And this can be done in two ways depending on the requirement.

1. Synchronized block and
2. Synchronized method.

if you go for synchronized block it will lock a specific object.

if you go for synchronized method it will lock all the objects.

in other way Both the synchronized method and block are used to acquires the lock for an object. But the context may vary. Suppose if we want to invoke a critical method which is in a class whose access is not available then synchronized block is used. Otherwise synchronized method can be used.

Synchronized methods are used when we are sure all instance will work on the same set of data through the same function Synchronized block is used when we use code which we cannot modify ourselves like third party jars etc