Discuss each of the following terms in the context of Java’s threading mechanisms:

a) synchronized
b) wait
c) notify
d) notifyAll
e) Lock
f) Condition

a) When a method or block is declared synchronized and it is running, the object is locked. Other threads cannot access the other synchronized methods of the object until the lock is released.
b) Places a thread in the waiting state until another thread calls notify or notifyAll on the same object or until a specified amount of time elapses.
c) Wake a thread currently waiting on the given object.
d) Wake all threads waiting on the given object.
e) An interface implemented by objects that control access to a resource shared among multiple threads. Only one thread can be holding a Lock at one time—a second
thread calling the lock method will block until the unlock method is called. Using
the Lock interface is more complicated than using the synchronized keyword, but is more flexible.
f) Objects of this interface represent condition variables that can be used with Locks to manage access to a shared resource.

Computer Science & Information Technology

You might also like to view...

The Surface Pro is built with a more traditional ________ hardware that lets it perform like a traditional PC

A) Intel chip B) operating system C) ARM chip D) Windows Phone chip

Computer Science & Information Technology

How have WLANs changed ‘hard edges' into ‘blurred edges'?

What will be an ideal response?

Computer Science & Information Technology