Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multithreading- synchronization

Status
Not open for further replies.

luvcloud

Programmer
Apr 23, 2002
24
0
0
MY
Can someone pls explain what this paragraph means :


" What Java is lacking (and what C# has) is the ability to attempt to enter a synchronized code segment without blocking on the acquisition of the lock. C#'s Monitor class not only contains the Enter method, which blocks until it can be assured that it will be the only thread in the block, but it also contains a TryEnter method, which will either obtain a lock (optionally blocking for a given amount of time) or return with a return value of false, signifying that it cannot get a lock on the object."

I do not understand the sentence underlined.
 
Basically this means that in Java when you call a synchronized method if there is already something accessing the method then you have no choice but to block and wait.

In C# you have the ability to block and wait or to wait for a specified amount of time before giving up.

This most likely taken from C++ Posix threads. It would be nice to have in Java but in most cases it is not necessary. In any case, you could write your own API to allow this type of functionality, it is just not explicitly handled by the core language.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top