Question

What methods must a class implementing the java.util.concurrent.locks.Lock interface implement? Describe some of the expected characteristics...

What methods must a class implementing the java.util.concurrent.locks.Lock interface implement? Describe some of the expected characteristics of each of the methods of this interface?

Homework Answers

Answer #1

Lock interface provide these unimplemented methods -

1- void lock() acquire the lock if it's available; if the lock isn't available a thread gets blocked until the lock is released.

2- void lockInterruptibly() – this is similar to the lock(), but it allows the blocked thread to be interrupted and resume the execution through a thrown java.lang.InterruptedException

3- boolean tryLock() – this is a non-blocking version of lock() method; it attempts to acquire the lock immediately, return true if locking succeeds

4- boolean tryLock(long timeout, TimeUnit timeUnit) this is similar to tryLock(), except it waits up the given timeout before giving up trying to acquire the Lock

5- void unlock() – unlocks the Lock instance

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using the interface and class definitions below, write the headings of all of the methods which...
Using the interface and class definitions below, write the headings of all of the methods which still need to be defined in the class Class2. https://hastebin.com/kopejolila.java public interface Interface1 { public float method1(int i) ; } public interface Interface2 extends Interface1 { public int method2(int i) ; public void method3(int i) ; } public abstract class Class1 { public float method1(int anInt) { return anInt * 2.0f ; } public abstract void method3(Object anObject) ; public abstract void method4(int anInt)...
Which of the following can be member of interface? Static field members Static properties Static methods...
Which of the following can be member of interface? Static field members Static properties Static methods Static constructors None of the above Every collection class must implement ____________ interface? IEnumerator IEnumerable IList IDictionary Numbers of items which can be added to ArrayList are fixed and decided by its Capacity which cannot bechanged. True False Closely related data can be handled more efficiently in memory when grouped together into a__________ Collection Database File Class
What are the top five challenges in implementing HIEs? In your view, what are some methods...
What are the top five challenges in implementing HIEs? In your view, what are some methods by which these challenges can be overcome? Give reasons why you think the methods proposed could overcome the challenges. (Approximate length: 300-400 words)
Consider the following interface: interface Something {     boolean validate(int value); } Classes that implement “Something”...
Consider the following interface: interface Something {     boolean validate(int value); } Classes that implement “Something” interface can validate a specific value in different behaviors within some context. For example, this interface could be useful to program a candy dispenser machine to check whether the coin inserted is a valid coin such as a quarter with a diameter of 2.426 centimeters. Also, it could be useful to check if there is any candy available to dispense. Write two classes “Coin”...
Consider the following interface: interface Something {     boolean validate(int value); } Classes that implement “Something”...
Consider the following interface: interface Something {     boolean validate(int value); } Classes that implement “Something” interface can validate a specific value in different behaviors within some context. For example, this interface could be useful to program a candy dispenser machine to check whether the coin inserted is a valid coin such as a quarter with a diameter of 2.426 centimeters. Also, it could be useful to check if there is any candy available to dispense. Write two classes “Coin”...
What methods does JTable implement which are required by the interfaces implemented by the JTable class...
What methods does JTable implement which are required by the interfaces implemented by the JTable class beyond those interfaces implemented by the various parent classes of JTable?
Describe the characteristics of an abstract class in java
Describe the characteristics of an abstract class in java
What is the purpose of aggregate planning? Describe some demand and capacity options for implementing plans....
What is the purpose of aggregate planning? Describe some demand and capacity options for implementing plans.
What are some different types of stalkers and features of stalking (Describe some of their characteristics)?...
What are some different types of stalkers and features of stalking (Describe some of their characteristics)? What are some explanations for why stalking behaviors occur?
Create and implement a class called clockType with the following data and methods Data: Hours, minutes,...
Create and implement a class called clockType with the following data and methods Data: Hours, minutes, seconds Methods: Set and get hours Set and get minutes Set and get seconds printTime(…) to display time in the form of hh:mm:ss default and overloading constructor
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT