please explain me the flow of this program
class Bticket extends Thread
{
Object train,comp;
Bticket(Object train,Object comp){
this.train=train;
this.comp=comp;
}
public void run(){
synchronized(train){
System.out.println("bookticket locked on train");
try{
Thread.sleep(200);}
catch(InterruptedException ie){}
}
System.out.println("bookticket now waiting to lock on comp");
synchronized(comp){
System.out.println("bookticket locked on comp");
}
}
}
class Cticket extends Thread
{
Object train,comp;
Cticket(Object train,Object comp){
this.train=train;
this.comp=comp;
}
public void run(){
synchronized(train){
System.out.println("cancellticket locked on train");
try{
Thread.sleep(200);}
catch(InterruptedException ie){}
}
System.out.println("cancellticket now waiting to lock on comp");
synchronized(comp){
System.out.println("cancelticket locked on comp");
}
}
}
class Deadlock1
{
public static void main(String[] args)
{
Object tr = new Object();
Object compartment =new Object();
Bticket bt=new Bticket(tr,compartment);
Cticket ct = new Cticket(tr,compartment);
Thread t1=new Thread(bt);
Thread t2 = new Thread(ct);
t1.start();
t2.start();
}
}
View Answers
Ads
Related Tutorials/Questions & Answers:
Please explain me the flow of this program..
Please explain me the
flow of this
program.. // Substring replacement.
class StringReplace {
public static void main(String args[]) {
String org = "This is a test. This is, too.";
String search
please explain me the flow of this program
please explain me the
flow of this program class Bticket extends Thread
{
Object train,comp;
Bticket(Object train,Object comp){
this.train=train;
this.comp=comp;
}
public void run(){
synchronized
Advertisements
please tell me the flow of execution of this program
please tell
me the
flow of execution of this program class Test{
int x;
Test(int x){
this.x=x;
}
static void access(){
System.out.println("x= "+x);
}}
class Static{
public static void main(String ar[]){
Test obj=new Test(55
please eslain me the flow of execution of this program
please eslain
me the
flow of execution of this program class Producer extends Thread
{
StringBuffer sb;
boolean dataprodover = false;
Producer(){
sb = new StringBuffer();
}
public void run(){
for(int i=1;i<=10;i++){
try
please explain this program
please explain this program public class MainClass {
public static void main(String[] args) {
System.out.println("Java
please help me in coding this given program
please help
me in coding this given program consider the below... are the prime numbers in ascending order
write a
program to find the nth term in this series.
(i m unable to code this
program..
please provide solution
please help me in coding this given program
please help
me in coding this given program consider the below... are the prime numbers in ascending order
write a
program to find the nth term in this series.
(i m unable to code this
program..
please provide solution
Please explain Hibernate Sessionfactory.
Please explain Hibernate Sessionfactory. Hi there,
Please explain..., the tutorials here will help you learn Hibernate and will
explain about hibernate...
Complete Hibernate 3.0 and Hibernate 4 Tutorial
Let
me know if the problem persists
how can i write this program ?please suggest me
how can i write this
program ?
please suggest me
Program to calculate the sum of two big numbers (the numbers can contain more than 1000 digits). Don't use any library classes or methods (BigInteger etc
Please explain @interface with an example
Please explain @interface with an example Here is the code snippet...)
private Runnable runnable;
where Runnable is an interface.
Could you
please explain what does all these mean?
How all these work
Please explain @interface with an example
Please explain @interface with an example Here is the code snippet:
@Retention(RUNTIME)
@Target({ FIELD })
public @interface InjectProperty... runnable;
where Runnable is an interface.
Could you
please explain what does
please explain this prog
please explain this prog can u
explain this
import java.io.*;
class SString{
public static void main(String ar[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in
Please explain the logic....
Please explain the logic.... class A1 { }
class B extends A1 { }
public class ComingThru {
static String s = "-";
public static void main(String[] args) {
A1[] aa = new A1[2];
B[] ba = new B[2
please explain this prog
please explain this prog import java.io.*;
class Studar{
public static void main(String ar[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("how many
urgent...pleAse help me.....please!
urgent...
pleAse help
me.....
please!
please help
me urgent! how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
please help me.
please help
me.
Please send
me a code of template in opencms and its procedure.so i can implement the code.
Thanks
trinath
please help me.
please help
me. How to read a properties file in java with a suitable example.
Please send
me.
Thanks
Trinath
Please visit the following link:
Java read properties file
help me please
help
me please Hello
I want helping for this question ,
Please
Write a
program that reads some friends� names, stores them in an array, and then prints out on the screen all friends who start by a particular letter
please help me.
please help
me.
Please send
me the validation of this below link.
the link is http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html
Thanks
Trinath
please help me to this problem..
please help
me to this problem.. i wrote a
program like keyboard and i used [JTextFiled] means that just you can write inside the
program (i.e inside the JTextField) but i want to make this
program to let
me write where i
please tell me
please tell me i have created one table,when i close and again login, table name will be there, but its content not displayed, showing as no rows selected,
please tell
me the reason