/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.concurrent.locks.ReentrantLock;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static class Person extends Thread { //Человек

		public Person(String name) {

		super(name);
			run();
		}

		@Override
		public void run() {
			Iron.ironLock.lock();
			try {
				Iron iron = takeIron();
				Clothes clothes = takeClothes();
				ironing(iron, clothes);
				returnIron();
			} finally {
				Iron.ironLock.unlock();
			}
		}

		protected Iron takeIron() {
			System.out.println("Taking an Iron");
			return new Iron();
		}

		protected Iron returnIron() {
			System.out.println("Returning the Iron");
			return new Iron();
		}

		protected Clothes takeClothes() {
			return new Clothes("T-shirt");
		}

		protected void ironing(Iron iron, Clothes clothes) {
			System.out.println(getName() + "'s ironing the " + clothes.name);
		}
	}

	public static class Iron {
		static ReentrantLock ironLock = new ReentrantLock();
	} //Утюг

	public static class Clothes {//Одежда
		String name;

		public Clothes(String name) {
			this.name = name;
		}
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Person diana = new Person("Diana");
		Person igor = new Person("Igor");
	}
}

