Home Answers Viewqa Java-Beginners plese expalin the flow of this program

 
 


kalyanichandra
plese expalin the flow of this program
0 Answer(s)      a year and 6 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();

}

}

View Answers









Related Pages:
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
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
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
flow charts
flow charts   draw a flow chart program with a user prompt of 5 numbers computing the maximum, minimum and average
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
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
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
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
Loop Control flow enhancement discussion - Java Tutorial
/implement regular program flow. I just picked up some code from another group... that Exception Handling is good for general Program Flow enhancement ( Loop breaking.... Throwing exceptions to change program flow is VERY bad, I agree 100
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
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
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
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 Flow In Depth
Struts Flow In Depth  Struts Flow In Depth
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 control data flow
Struts control data flow  How Struts control data flow
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
Java Review: Control Flow
Java Review: Control Flow Java uses the dominant imperative control flow paradigm. Other paradigms are declarative programming and data flow. Structured Programming control flow primitives within a method: Sequence
What is the general flow of Hibernate communication with RDBMS?
What is the general flow of Hibernate communication with RDBMS?  Hi, What is the general flow of Hibernate communication with RDBMS? thanks
How to make animated flow river, make animated flow river, animated flow river
How to make animated flow river       Now you can make animation of the still river picture, it is very interesting because I have tried here to make a realistic animation
if-else Flowchart equivalent
flowchart. There are several graphical ways to show the flow of programs. Here is a program fragment and the equivalent flowchart... the the flow of execution. Boxes contain one or more Java statements
Flex terminating event flow example
Flex terminating event flow example       In the example below, how to terminate an event flow is demonstrated. With this example the motive of previous event phase detecting
i got illegal start of expression error , plese tell me the mistake where i did...
i got illegal start of expression error , plese tell me the mistake where i did...   import org.springframework.context.*; import java.util.*; public class MyListener implements ApplicationListener { public static void main
How to use switch statement in jsp code
How to use switch statement in jsp code       switch is a type of control statement used to control the flow of program execution. Its body is known as a switch block
Flow Control Constructs
Flow Control Constructs       Flow Control Constructs include the IF, CASE, LOOP, WHILE, ITERATE... label The LEAVE Statement is used to exit from any flow control constructs
Classes in Java
of the program. An exception is an event that occurs and  interrupts the normal flow of instructions. That is exceptions are objects that store... earlier always resulted in a program crash. However, some programming languages like
Example of Flow Control Tags of JSTL Core Tag Library
Example of Flow Control Tags of JSTL Core Tag Library...://java.sun.com/jsp/jstl/core" %> JSTL core library provides following tags for flow... of Flow Control tags of JSTL Core tag library. We have also used tag <c:out>
Java if else
; The if-else statement is one of the widely used control flow statements while programming. It lets the program execute a set of statements enclosed within the "if" block only if the certain condition evaluates to true otherwise program
Complete j2ee technical flow - Design concepts & design patterns
Complete j2ee technical flow  Hi Friends. I want complete technical flow of j2ee project with following technologies.jsp , servlet , Struts , Hibernate , (should follow mvc-2 design pattern) . with DAO ,DTO SERVICE
Need J2ee project technical flow - Design concepts & design patterns
Need J2ee project technical flow   Hi friend,am newbie to web development.I need j2ee project technical project flow. For example Browser ---> Controller --> Servlet(validator) <
Controlling your program
flow statement. It directs the program to execute a certain section of code... Control Statments       We all know that the execution of the statements in a program takes
Java Break out of for loop
Java Break out of for loop       In loop programming the program flow is continued till... it out of the loop. While 'continue' label just stops the program flow at line where
SCJP Module-5 Question-5
; System.out.println(j); }} What will be the result of above code ? (1) The program compilation fails because of line number 3. (2) 1 (3) 3 (4) The program compilation fails because of line number 5. Answer: (4) Explanation: This program
Java - The switch construct in Java
also turns the normal flow control of the program as per conditions. It works.... In this Program you will see that how to use the switch statement. This program take a number and check weather the number lies between 1 to 7. If user
program
program  any program of hotel or school management
program
program  program of jdbc using ms access for creating table
program
program  write a javascript program to create a application form with validation
program
program  write a html program in show table and this word in box
program
program  write a program different between to dates in terms of days in java
Java Switch Statement
Java Switch Statement       In java, switch is one of the control statement which turns the normal flow control of the program as per conditions. It's like if-else statement but it can
program
program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.