Hai friends,
In synchronization block why we are passing this or object?
public int getCount() {
synchronized (this)
{
return count;
}
synchronized (obj)
{
}
please clear by doubt?
Hai friends,
In synchronization block why we are passing this or object?
public int getCount() {
synchronized (this)
{
return count;
}
synchronized (obj)
{
}
please clear by doubt?
They both work. Depends on how granular you want the syncronisation to be.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.