Please clarify my doubt

Please clarify my doubt

/here is my sample code for deadlock/

class A { synchronized void foo(B b) { String name = Thread.currentThread().getName(); System.out.println(name + "entered A.foo()"); /*try { //Thread.sleep(1000); } catch(InterruptedException e) { System.out.println("A Interrupted"); }*/ System.out.println("Trying to call B.last()"); b.last(); } synchronized void last() { System.out.println("Inside A.last()"); } } class B { synchronized void bar(A a) { String name = Thread.currentThread().getName(); System.out.println(name + "entered B.bar()"); /*try { Thread.sleep(1000); } catch(InterruptedException e) { System.out.println("B Interrupted"); }*/ System.out.println("Trying to call A.last()"); a.last(); } synchronized void last() { System.out.println("Inside B.last()"); }

} class Deadlock implements Runnable { A a = new A(); B b = new B(); Deadlock() { Thread.currentThread().setName("Main Thread"); Thread t = new Thread(this,"Racing Thread"); t.start(); a.foo(b); System.out.println("Back in Main Thread"); } public void run() { b.bar(a); System.out.println("Back in other thread"); } public static void main(String[] args) { new Deadlock(); }

} My question is that class A has 2 synchronized methods.Object a of class A is calling a.last method .Why it is not entering into last method ??? If class has 2 synchronized methods as in the example if same object of the class calls both the methods will it give access to both of those methods???

View Answers









Related Tutorials/Questions & Answers:
Please clarify my doubt
Please clarify my doubt  /here is my sample code for deadlock/ class A { synchronized void foo(B b) { String name...[] args) { new Deadlock(); }ADS_TO_REPLACE_1 } My question
Clarify my doubt - JSP-Servlet
Clarify my doubt  Hi All, Although i know the concept of Servlet & JSP, but I have never got a chance to work in EJB . So could u please tell me how to create web Project in netbeans and deploy it in tomcat AND/OR creating a web
Advertisements
please clarify regarding capacity method of my below string buffer class example
please clarify regarding capacity method of my below string buffer class example  hi here is the program below: > import java.lang.*; public... vinodaRajDeepakMohit vinodaRajDeepakMohitraju length is24 capacity is30 my question
clarify my question - Java Beginners
clarify my question  Dear Sirs/Expert, Thanks for writing back. Yes. I want a page to use id of parents to do the search for the match. So... the matching tutors to the parent. I was telling you that my degree
Clarify my last question's answer - Java Beginners
Clarify my last question's answer  Dear expert, I've tried out... expert's advise. Many thanks.   Hi Friend, Please clarify your... did not specify my question too clearly. Here's my 2 database
Doubt
Doubt  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details
PLEASE HELP WITH MY JAVA
PLEASE HELP WITH MY JAVA  Hey my name is Gavin and im a student at school that takes IT. my teacher has gave me a problem and i can't figure it out please help!!!!!!!! it is a for-loop question: Display the first 5 multiples
doubt in my program code - Java Beginners
doubt in my program code  i have developed a web browser... the name on that button.can u please help me out to solve this problem.if u need.... FAYAZ.  Hi friend, Please specify your requirements in detail
Please Help To Solve My Problem
Please Help To Solve My Problem  PHP I Have 6 Textbox and 1 ok button. 6 Textbox to Add the 6 Team Name. Each Team Name In String(Like- A,B,C,D,E,F) When I Add This Six Team Name In Six Text Box Then I Will Click On Ok Button
please help.. this my importtant project..!!!!!
please help.. this my importtant project..!!!!!  Consider the Algebra: Solving quadratic equations. The two roots of a quadratic equation ax2 + bx + c = 0 can be obtained using the formula: ð???ð???ð???ð??¡1= â??ð???+â??ð???2â
My big doubt on java prgmn.. need solution asap
My big doubt on java prgmn.. need solution asap  How do you write prgrm 4 dis : 3% discount is given if payment is made within 30days of purchase. date of purchase and payment entered by user
My screen EPAD is broken ...please help
My screen EPAD is broken ...please help   iam in iraq and my screen EPAD is broken ,.please help..can tel me a place to join it to solve this problem ?..Sory
Doubt
User request form  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action="page2.html
Doubt
How to load page  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action="page2.html
Doubt
Submit and process form  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action
Doubt
load next page after submitting  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action
doubt this
doubt this  what is the use of "this" and "super" keyword
Help me please with my final homework
Help me please with my final homework  Write a Java program of your choice that demonstrates the following concepts: ? Input and Output. ? Selection/Conditional (e.g. if statement). ? Arithmetic. ? Loops. ? Arrays
DOUBT ?
DOUBT ?  in c++ member function of a class must be public
plz try to clear my doubt for shuffling multi-dimensional array
plz try to clear my doubt for shuffling multi-dimensional array  hi, if v r using Arrays.asList() means, it may shuffle the row wise list only... v want to shuffle the ful entire multi-simensional array means wat v want to do
Syntax error in my UPDATE..please advise
Syntax error in my UPDATE..please advise  Hi experts, I tested my...; stmt.executeUpdate(sql); Please advise how should I change my SQL to use Heidi MySQL...) And here's my UPDATE Statement: String sql = "UPDATE members SET strNRICNO
Not sure whats wrong with my code HELP PLEASE?!?!
Not sure whats wrong with my code HELP PLEASE?!?!  I cant figure out what I am doing wrong in my code can anyone help me out??? Grades ADS_TO_REPLACE_1 function computeGrade( ) { var hw, lab, midt, fin, avg; hw
doubt
doubt  can you please explain the following code System.out.print((k >=10) ?+ k : " " + k
ModuleNotFoundError: No module named 'Clarify'
ModuleNotFoundError: No module named 'Clarify'  Hi, My Python... 'Clarify' How to remove the ModuleNotFoundError: No module named 'Clarify... to install padas library. You can install Clarify python with following command
this is my javascript code and i am not understanding the mistake in this,please help me?
this is my javascript code and i am not understanding the mistake in this,please help me?  <html> <h2>Form Validation</h2>...; if((nn1.value==null)||(nn1.value=="")){ alert("Please Enter
please do respond to my problem sooooon sir - Java Beginners
please do respond to my problem sooooon sir  Hello sir, Sir i have... on the link in my browser the link is opened in the internet explorer.i need to open the link also in my own browser.Hope you will help me out.And also sir i need
Please help me to modify my java code from php code
Please help me to modify my java code from php code  i want to covert...) ... but this is not giving me the exact result as the above PHP code is giving. So please...;   Thank you , But this not my exact solution for my problem. What
Please help me to modify my java code from php code
the exact result as the above PHP code is giving. So please help me to convert
I need help on my Java code.... please please help me out!?
I need help on my Java code.... please please help me out!?  Well my... in the file. Also it should be displayed on the screen. However my code doesn't display the anagram on screen or the output file! Please show me whats wrong. Thanks i
ModuleNotFoundError: No module named 'clarify_python'
ModuleNotFoundError: No module named 'clarify_python'  Hi, My... named 'clarify_python' How to remove the ModuleNotFoundError: No module named 'clarify_python' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'clarify_python_2'
ModuleNotFoundError: No module named 'clarify_python_2'  Hi, My... named 'clarify_python_2' How to remove the ModuleNotFoundError: No module named 'clarify_python_2' error? Thanks   Hi, In your
clarify date class - Java Beginners
clarify date class  Dear, clarify this question... "Develop Date class in Java similar to the one available in java.util package. Use JavaDoc... in java.util or any packages.. please. thanks in advance. regards S.v.Doss
ModuleNotFoundError: No module named 'clarify_brightcove_sync'
ModuleNotFoundError: No module named 'clarify_brightcove_sync'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'clarify_brightcove_sync' How to remove the ModuleNotFoundError
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how... our own plugin????? and please help me. how to use dao s while integrating... ????? (adsbygoogle = window.adsbygoogle || []).push({}); please help meee
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how... our own plugin????? and please help me. how to use dao s while integrating... ????? (adsbygoogle = window.adsbygoogle || []).push({}); please help meee
this is my file upload page, here i am not getting tags input field value to my servlet,please suggest a solution?
this is my file upload page, here i am not getting tags input field value to my servlet,please suggest a solution?  <html> <head> <script type="text/javascript"> var counter =1; function
doubt in struts - Struts
doubt in struts   i don't understand the concept on Resource bundle in struts can u please help me out
Please tel me .In my System Oracle9i and J2sdk1.6 are Installed.Why this problem occures and what is the solution?
Please tel me .In my System Oracle9i and J2sdk1.6 are Installed.Why this problem occures and what is the solution?  Exception in thread "main" java.lang.UnsupportedClassVersionError: select (Unsupporte d major.minor version 50.0
Validation doubt
Validation doubt  hi..... thanks for the other validation code. I have got that and implemented in my code but i have a doubt in that. As we try... think i am able to tell u what i want to and u have got whats my doubt. plz give
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page  <p>?xml version='1.0' encoding...; Please visit the following link: JSF Example
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page
;   Please visit the following link: JSF
doubt on synchronized block in java
. I think you got my doubt. I request you to clarify my doubt based on below...doubt on synchronized block in java  Hi ! some people are feeling bore on my regular questions on threads. Do not feel bore on my regular questions.I
Doubt Regarding Charts
Doubt Regarding Charts  Hi, Can you please help me out by answering "hoe to include charts in core java code and struts code" thanks in advance, Swaroop Eswara   Please visit the following link: Jfreechart
doubt
doubt
Doubt
DOUBT
doubt
doubt
Doubt in struts - Struts
Doubt in struts  I am new to Struts, Can anybody say how to retrieve... know how to do. Please help me in this regard. It will be helpful, if explained with code?  Hi friend, Please visit the link to solve the problem

Ads