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){ 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 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
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 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
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
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
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
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
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
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
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
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
program
program   An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes
program
program  write a java program to input a no. and print wheather the no. is a special no or not. (special no. are those no whose factorial of the sum of digit of the no is same as the original
program
program  Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder
program
program  explanation of program on extending thread class   Hi Friend, Please go through the following link:ADS_TO_REPLACE_1 Java Threads Thanks
program
program  Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean
program
program  how to improve programming skills plss tell some tips..i am understanding concepts but unable to write program so,pls give some guideness plsss
Program
Program  a program to prove that default constructor of super class is available to subclass by default. Define a parameterize constructor for super class to store name = â??Tommyâ?? age=â??23â?? and call this constructor
Program
Program  a program to create two classes Commercial and Domestic. Override the method calculatebill() of Commercial class(Rs.8 per unit) into Domestic class(Rs 6 per unit) to compute electricity bill for both classes
program
program  no i want a program that shows how merge sort algorithm works in graphical representations like numbers are taken in circles and computation... in rectangles or circles wat ever it may be. the theme of program is to show algorithm
program
program  . Develop a program that accepts an initial amount of money (called the principal), a simple annual interest rate, and a number of months will compute the balance at the end of that time. Assume that no additional
program
program  Write a JSP Program, which displays a web page containing the name of the Courses, Courses being offered currently, number of students enrolled in each course, new courses to be offered, eligibility criteria for taking
program
program  i want a progra in java to print a sentence in alphabetic order, taking the input from the user.the program should writen without using the array for example : if input= this is a cat then output sould = a cat
program
program  Utopias tax accountants always use programs that compute income taxes even though the tax rate is a solid, never-changing 15%. Define the program calculateTax which determines the tax on the gross pay. Define
program
program  Write a JSP Program, which displays a web page containing two web links one for your profiling and other for the schedule of theory of practical classes of your Batch. When one click on link for getting your profile
program
program  Write a program to print details of a week for a particular day using array of objects Integer and String. OUTPUT: First Day of Week is Monday Second Day of Week is Tuesday Third Day of Week is Wednesday Forth Day
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
flow charts
flow charts   draw a flow chart program with a user prompt of 5 numbers computing the maximum, minimum and average
ModuleNotFoundError: No module named 'flow'
ModuleNotFoundError: No module named 'flow'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'flow' How to remove the ModuleNotFoundError: No module named 'flow' error
ModuleNotFoundError: No module named 'flow'
ModuleNotFoundError: No module named 'flow'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'flow' How to remove the ModuleNotFoundError: No module named 'flow' error
program
program
program
program
program
program
Program
Program
Program
Program

Ads