Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

plese expalin the flow of this program

Ads

 
 

Share on Google+Share on Google+

kalyanichandra
plese expalin the flow of this program
0 Answer(s)      5 years and 8 months ago
Posted in : Java Beginners

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(150);} 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(comp){ System.out.println("cancellticket locked on comp"); try{ Thread.sleep(200);} catch(InterruptedException ie){} } System.out.println("cancellticket now waiting to lock on train"); synchronized(train){ System.out.println("bookticket locked on train");

}
}

}

class Deadlock { 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();

}

}

Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
plese expalin the flow of this program
plese expalin 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
plese tell me the control flow of this program
plese tell me the control flow of this program  public class starForTest { public static void main(String [] args) { for (int... k....? plese tell me the control flow
Advertisements
what error in this program plese correct it
what error in this program plese correct it  import java.io.*; class y { public static void main (String args[]) { Data inputStream dis = new Data inputstream(System.in); float l,b,a; Systyem.out.println("enter the lengh"); l
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
plese help
plese help  i need a program to convert a decimal num into binary num in java language by using array and loop   Java Convert decimal to binary import java.util.*; public class DecimalToBinary{ public static void
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
flow charts
flow charts   draw a flow chart program with a user prompt of 5 numbers computing the maximum, minimum and average
jquery issue plese help
jquery issue plese help  Im am trying to Change the background color of the dashboard to black with an opacity of 0.6 Change the opacity of the images in the dashboard to 0.5 before the dashboard slides out. Change the opacity
Expalin the Web Hosting Bandwidth/Space/Transfer
Expalin the Web Hosting Bandwidth/Space/Transfer  Trying to find the basics of the web hosting. I want to know about the Bandwidth, space and the data transfer terms. Explain me all these concepts. Thanks   Hello
plese tell -Struts or Spring - Spring
plese tell -Struts or Spring  Hello, i want to study a framework. i have some basic overview of Struts1.1 and Strurts 2.0. i don't know much about spring. which frameork i should do Struts or Spring and which version. i
plese send information how to do this - Development process
plese send information how to do this  present i am doing project on javaServlets,jsp,javascript plese see this i have created like subject: button:ok textfield mail: textarea footer
Struts Flow
Struts Flow  can u explain about struts flow with clear explaination  Hello, Please visit the following link: http://www.roseindia.net/struts/ Thanks
Struts Flow In Depth
Struts Flow In Depth  Struts Flow In Depth
flow chart
flow chart  can you provide the flowchart of this coding. import java.util.*; public class StudentMarks{ double totalMarks; String grade; public void setTotalMarks(double totalMarks){ this.totalMarks=totalMarks
flow chart
flow chart  can you provide the flowchart of this coding. import java.util.*; public class StudentMarks{ double totalMarks; String grade; public void setTotalMarks(double totalMarks){ this.totalMarks=totalMarks
Struts control data flow
Struts control data flow  How Struts control data flow
expression and flow control
expression and flow control  write the program calculate and print the bill of communication telephone mobile company the company offer 2 types of services is regular (r) and premium (p) the rates are computed as follow
Version of com.bookislife>flow dependency
List of Version of com.bookislife>flow dependency
Version of com.intersult>flow dependency
List of Version of com.intersult>flow dependency
Flow control of hibernate application..
Flow control of hibernate application..  Hello Roseindia team, Please provide flow control of hibernate application.. i.e when it goes to mapping file? when it goes to DAO's? when it goes to hibernate config files?? etc
Control Flow Statements in java 7
Flow Statements : - In general program execution flow is from top to bottom but you can also control flow of your program with the help of control flow.... So control flow statements break the flow of program and flow under some
Version of ch.jodersky>flow-core_2.11 dependency
List of Version of ch.jodersky>flow-core_2.11 dependency
Version of ch.jodersky>flow-core_2.12 dependency
List of Version of ch.jodersky>flow-core_2.12 dependency
Version of ch.jodersky>flow-core_2.12.0-M4 dependency
List of Version of ch.jodersky>flow-core_2.12.0-M4 dependency
Version of ch.jodersky>flow-core_2.12.0-M5 dependency
List of Version of ch.jodersky>flow-core_2.12.0-M5 dependency
Version of ch.jodersky>flow-core_2.12.0-RC1 dependency
List of Version of ch.jodersky>flow-core_2.12.0-RC1 dependency
Version of ch.jodersky>flow-native dependency
List of Version of ch.jodersky>flow-native dependency
Version of ch.jodersky>flow-stream_2.11 dependency
List of Version of ch.jodersky>flow-stream_2.11 dependency
Version of ch.jodersky>flow-stream_2.12 dependency
List of Version of ch.jodersky>flow-stream_2.12 dependency