27 lines
487 B
Java
27 lines
487 B
Java
|
package reentrantrwlock;
|
||
|
|
||
|
public class Movie {
|
||
|
|
||
|
private final String title;
|
||
|
private final int duration;
|
||
|
|
||
|
public Movie(String title, int duration) {
|
||
|
this.title = title;
|
||
|
this.duration = duration;
|
||
|
}
|
||
|
|
||
|
public String getTitle() {
|
||
|
return title;
|
||
|
}
|
||
|
|
||
|
public int getDuration() {
|
||
|
return duration;
|
||
|
}
|
||
|
|
||
|
public void play() throws Exception {
|
||
|
Thread.sleep(duration);
|
||
|
System.out.println("[" + Thread.currentThread().getName()
|
||
|
+ "]: I've finished watching movie: " + title);
|
||
|
}
|
||
|
}
|