Resolves checkstyle errors for remaining m (#1090)

* Reduces checkstyle errors in marker

* Reduces checkstyle errors in master-worker-pattern

* Reduces checkstyle errors in mediator

* Reduces checkstyle errors in memento

* Reduces checkstyle errors in model-view-controller

* Reduces checkstyle errors in model-view-presenter

* Reduces checkstyle errors in module

* Reduces checkstyle errors in monad

* Reduces checkstyle errors in monostate

* Reduces checkstyle errors in multiton

* Reduces checkstyle errors in mute-idiom

* Reduces checkstyle errors in mutex
This commit is contained in:
Anurag Agarwal
2019-11-16 18:18:23 +05:30
committed by Ilkka Seppälä
parent 3ccc9baa1a
commit 1fdc650545
66 changed files with 374 additions and 423 deletions

View File

@ -25,19 +25,17 @@ package com.iluwatar.mutex;
/**
* A Mutex prevents multiple threads from accessing a resource simultaneously.
* <p>
* In this example we have two thieves who are taking beans from a jar.
* Only one thief can take a bean at a time. This is ensured by a Mutex lock
* which must be acquired in order to access the jar. Each thief attempts to
* acquire the lock, take a bean and then release the lock. If the lock has
* already been acquired, the thief will be prevented from continuing (blocked)
* until the lock has been released. The thieves stop taking beans once there
* are no beans left to take.
*
* <p>In this example we have two thieves who are taking beans from a jar. Only one thief can take
* a bean at a time. This is ensured by a Mutex lock which must be acquired in order to access the
* jar. Each thief attempts to acquire the lock, take a bean and then release the lock. If the lock
* has already been acquired, the thief will be prevented from continuing (blocked) until the lock
* has been released. The thieves stop taking beans once there are no beans left to take.
*/
public class App {
/**
* main method
* main method.
*/
public static void main(String[] args) {
Mutex mutex = new Mutex();

View File

@ -24,9 +24,8 @@
package com.iluwatar.mutex;
/**
* A Jar has a resource of beans which can only be accessed by a single Thief
* (thread) at any one time. A Mutex lock is used to prevent more than one Thief
* taking a bean simultaneously.
* A Jar has a resource of beans which can only be accessed by a single Thief (thread) at any one
* time. A Mutex lock is used to prevent more than one Thief taking a bean simultaneously.
*/
public class Jar {

View File

@ -34,16 +34,15 @@ public class Mutex implements Lock {
private Object owner;
/**
* Returns the current owner of the Mutex, or null if available
* Returns the current owner of the Mutex, or null if available.
*/
public Object getOwner() {
return owner;
}
/**
* Method called by a thread to acquire the lock. If the lock has already
* been acquired this will wait until the lock has been released to
* re-attempt the acquire.
* Method called by a thread to acquire the lock. If the lock has already been acquired this will
* wait until the lock has been released to re-attempt the acquire.
*/
@Override
public synchronized void acquire() throws InterruptedException {

View File

@ -27,20 +27,20 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Thief is a class which continually tries to acquire a jar and take a bean
* from it. When the jar is empty the thief stops.
* Thief is a class which continually tries to acquire a jar and take a bean from it. When the jar
* is empty the thief stops.
*/
public class Thief extends Thread {
private static final Logger LOGGER = LoggerFactory.getLogger(Thief.class);
/**
* The name of the thief.
* The name of the thief.
*/
private final String name;
/**
* The jar
* The jar.
*/
private final Jar jar;
@ -50,8 +50,7 @@ public class Thief extends Thread {
}
/**
* In the run method the thief repeatedly tries to take a bean until none
* are left.
* In the run method the thief repeatedly tries to take a bean until none are left.
*/
@Override
public void run() {