This programs hangs after printing two lines. How can i correct it?

public class ThreadTest {
     static class FirstThread implements Runnable {
          public synchronized void run() {
               try {
                    wait();
               } catch (InterruptedException e) { }
               System.out.println("First thread starts");
               System.out.println("First thread ends");
     static class SecondThread implements Runnable {
          public synchronized void run() {
               System.out.println("Second thread starts");
               System.out.println("Second thread ends");
               notifyAll();
     public static void main(String[] args){
          Thread t1 = new Thread(new FirstThread());
          Thread t2 = new Thread(new SecondThread());
          t1.start();
          t2.start();
          try {
               t1.join();
          } catch (InterruptedException e) { }
It is giving output as :
Second thread starts
Second thread ends

Your two synchronizations should be on a same object for the wait/notify pair to be working. The object should be the one on which both wait and notify are called.
Message was edited by:
hiwa

Similar Messages

  • The information of photo like date change after close it. How can'i correct that

    the information of photo like date change after close it. How can'i correct that?

    Using the Photos ➙ Batch Change ➙ Date menu option will let you change the EXIF Capture Date of the photo.
    For a single photo (or to set a group of photos to the same date and time) use the Photos ➙ Adjust Date and Time ... menu option.
    Happy New Year

  • Programs hang after 10.3.9 how do i go back?

    i updated to 10.3.9 from 10.3.5 and now quicktime, reason, itunes and probly others wont open at all...i repaired perms and restarted i dont know what else to do. with the software update i installed the quicktime so it should be the corresponding version with my os.
    what should i do? how do i go back to 10.3.5?

    kindkind1:
    Let's start with Repair Disk. Here's how:
    Insert Installer disk and Restart, holding down the "C" key.
    Go to Installer menu (Panther and earlier) or Utilities menu (Tiger) and launch Disk Utility.
    Select your HDD (manufacturer ID) in the left panel.
    Select First Aid in the Main panel.
    (Check S.M.A.R.T Status of HDD at the bottom of right panel, and report)
    Click Repair Disk on the bottom right.
    If DU reports disk does not need repairs quit DU and restart.
    If DU reports errors Repair again and again until DU reports disk is repaired.
    If DU reports errors it cannot repair you will need to use a utility like Tech Tool Pro or Disk Warrior
    Please post back with further questions or comments.
    Good luck.
    cornelius

  • Printer off line how can I make it online?

    Ihave two laptop computers.  One I can print from, the other is constantly going offline.  My question is how do I make it online again?  My laptop is a Vaio.

    Hi @sam28 
    I would be happy to help you with your printer. Please first post back with the answers to these few questions.
    Is the printer connected wirelessly or with a USB cable?
    Is the printer connected directly to a wall outlet or a surge protector? (It is best to connect directly to the wall)
    Do  you have any other HP Printers installed on this computer? If so, do you still have the printers?
    What printer model do you have?  How Do I Find My Model Number or Product Number?
    What operating system do you have? Mac or Windows?
    While I wait to hear back from you, if you have Windows, and if you haven't already tried the HP Print and Scan Doctor, please do so and let me know the outcome. You will see a wrench, a yellow exclamation mark, a red X, or a check mark next each tested item.
    Click here to download and run the Print and Scan Doctor> www.hp.com/go/tools
    If the issue persists, please complete the steps in the following document and let me know the outcome; 'Printer is offline' Message Displays on the Computer and the Printer Will Not Print.
    Please click the Thumbs up icon below to thank me for responding.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Sunshyn2005 - I work on behalf of HP

  • Search option not working after updating Firefox. How can I correct this? Don't want to use Explorer, but will have to if we can't fix this.

    An automatic update ran this morning. Noticed when I started up the computer, a message came up saying that Firefox was running, even tho' it wasn't. Update finished, and now I cannot get the search tool to work. Help!!!

    Is this the search bar on the about:home page/
    Try to reset some preferences to the default with the SearchReset extension:
    *https://addons.mozilla.org/firefox/addon/searchreset/
    Note that the SearchReset extension only runs once and then uninstalls automatically, so it won't show on the "Firefox > Add-ons" page (about:addons).
    If there is a problem with searching via the default about:home page then try to reset the search engine used on the about:home page.
    Reset the <b>browser.startup.homepage_override.mstone</b> pref via the right-click context menu to the default on the <b>about:config</b> page and close and restart Firefox to restore the about:home page to its default.
    *http://kb.mozillazine.org/about:config
    #Open the <b>about:config</b> page via the location bar
    #Type in the Filter bar: mstone
    #Right-click the browser.startup.homepage_override.mstone line and select: Reset
    #Close and restart Firefox
    If this didn't help then delete the delete the chromeappsstore.sqlite file in the Firefox Profile Folder and repeat the above.
    You can also check for problems with preferences and try to rename or delete the prefs.js file and possible numbered prefs-##.js files and a possible user.js file to reset all prefs to the default values.
    *http://kb.mozillazine.org/Preferences_not_saved
    *http://kb.mozillazine.org/Resetting_preferences
    Also check that you do not have a mozilla.cfg file in the Firefox program folder.

  • I am showing 3.2 gb in mail after deleting all mail how can I correct this

    I am trying to reduce the amount of used memory on the iPhone Mail is showing usage of 3.2 gb even after deleting all mail.The memory did not change after getting rid of all trash, junk and saved emails. 

    Settings , iCloud , account, mail, advanced , deleted messages-remove. Remove after one day is the quickest way to get rid of these.

  • I delete an Init load, how can i  correct it

    Hi all,
    i deleted an Init load for a mistake, now this cube has a lot of data, how can i correct this mistake?

    Hello Jorge,
    it depends upon what is the data source.
    If the source is an DSO then just do an init without data transfer and thats all.
    If the source is an R/3 data source then you may have to do a new init without data transfer and then you can load the historical data through Full repair loads based on a selection which you think should cover the delta lost for that particular day.
    Since its a cube thereore first you should do a selective deletion from the cube for the same selections which you use to do full repair in the cube.
    Thanks
    Ajeet

  • Prints two lines perfect and then the next line cannot be read.

    Pixma MX882 When printing from computer or copying it prints two lines perfect, then the third line is not clear.  Can see letters are fuzzy (not clear, but can tell it tried to print)  Please help with any suggestions for correcting this problem. I have changed out the ink carts and run maintenance program.  Thanks.  Ross

    Hi rossfwalker,
    We recommend performing an automatic and manual print head alignment on the printer to see if this will resolve the issue. To do this, please follow the steps located here.  Should you still experience difficulty, the printer will require servicing; please call or email us using one of the methods on the Contact Us page for further assistance.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • The print is too small on various web sites that I open. How can I correct this?

    The print is too small on various web sites that I open. This has never happened on older Firefox versions. How can I correct this so every page I open, the print size is consistent and legible? I don't want to change it every time I open a new site.

    Hi Donna,
    Welcome to the HP Community Forum.
    Font Size and the scale (size) at which a document is printed is controlled within the application just before the job is sent to the printer -  this means the size is set from your browser (Firefox, Internet Explorer) or perhaps your Editor (Word).  Generally speaking, most applications use Print Preview -- or a variation of that program under a different name.
    An explanation and the use of Print Preview is avialble in the following document:
    Change Print Size with Print Preview
    Click the Kudos Thumbs-Up to show you appreciate the help.
    I am pleased to provide assistance on behalf of HP. I do not work for HP. 
    Click Accept as Solution when the Answer provides a Fix or Workaround!
    Kind Regards,
    Dragon-Fur

  • I maximized this program but I don't know how to make it smaller again.

    I maximized this program but I don't know how to turn it into a smaller box again. I've tried everything and I'm sure there must be some magic button I can't seem to find. Help?

    How about the green button in the upper left corner  or
    if you grab he slash marks in the lower right corner to shrink the window.
    If you zoomed in then try holding the control key and move two fingers on the trackpad.

  • "Are you sure you want to shut down your computer?" prompt pops up for no reason and continues to pop up after selecting Cancel. How can I stop this?

    "Are you sure you want to shut down your computer?" prompt pops up for no reason and continues to pop up after selecting Cancel. How can I stop this?
    Mac Pro. OS 10.6.8

    Then I suggest you read this thread regarding the 30" Apple Cinema Display and that particular message pop up... several possible causes... common denominator, the display.
    http://forums.macrumors.com/showthread.php?t=617367

  • When i bought this iMac i failed to register correctly and as i am trying to install a printer i need to do this when i am logging on. How can i create new password

    When i bought this iMac i failed to register correctly and as i am trying to install a printer i need to do this when i am logging on. How can i create new password

    See
    http://osxdaily.com/2011/08/24/reset-mac-os-x-10-7-lion-password/ and
    http://osxdaily.com/2011/09/19/change-password-mac-os-x-10-7-lion-without-knowin g-current-password/
    which also apply to Mtn Lion and Macericks.

  • InDesign CS5 is not opening after deactivation/activation. How can I fix this? Illustrator and Photoshop open and are working fine. Please help!

    InDesign CS5 is not opening after deactivation/activation. How can I fix this? Illustrator and Photoshop open and are working fine. Please help!

    First of all, thank you for replying so promptly to my posts this morning!
    I can't remember how I got the software on his computer, but I'm pretty sure it wasn't through migration assistant.
    I was looking into doing an uninstall of InDesign and a fresh install. However, I initially downloaded the CS5 suite digitally and I can't find out how I am able to perform a fresh install of InDesign. Do you know where I find this info or gain access to download just InDesign again? I can't seem to find anything in my Adobe account that shows where I might do another download.

  • Images appear fine in Photoshop cs6 and cc, but print too dark, and also show too dark in Windows picture viewer. How can I correct this? Is this a Photoshop setting issue or what?

    Images appear fine in Photoshop cs6 and cc, but print too dark, and also show too dark in Windows picture viewer. How can I correct this? Is this a Photoshop setting issue or what?

    Ok, look at your files in Photoshop. What is the profile assigned to them? You can find this out by going to the Status bar at the bottom, clicking on the right-pointing triangle and choosing document Profile from the list.
    Then in Windows, go to your Control Panel > Color Management and add sRGB (if it isn't there) and select it as your default profile.
    I hope that will work.

  • ICal keeps sending email notifications from all agenda items from the last 2 years. After laptop start up this action is repeated every hour. How can I stop these 300 emails coming in every hour?

    iCal keeps sending email notifications of all agenda items from the last 2 years (then I bought my laptop). After laptop start up this action is repeated every hour. How can I stop these >300 emails coming in every hour?

    Hi,
    We have rolled out a fix for this issue.
    Please log off and log back in to your machine and the issue should be resolved automatically. In case that does not work, please manually run the msi installer posted here (may require reboot).
    For details, please refer to the KB article here: Multiple RunOnce keys created 11.0.10 and 10.1.13 Acrobat | Reader
    Please let us know if you still face any issues.
    Thanks,
    Ashu Mittal

Maybe you are looking for

  • Skype for business - how do I get my chat groups?

    My company just implemented Skype for business.  I have some chat groups in my previous version of Skype desktop.  How do I get those chat groups into Skype for business? Thanks.

  • Handling DDE in 10G

    Hi all.. We are migrating 4.5 forms application to 10G. We have too many DDE calling pdfs, excels and external applications in the 4.5 forms. Now we are hosting everything in 10G AS, so all the DDE calls will now look for the files in the AS and will

  • GRN IDOC Transfer to ERP  - MBGMCR01 ( 2 IDOCS created)

    Hello Folks, We are on SRM 4 server 5 support Pack 10. and integrate to ERP 2004. When posting a confirmation (GRN) the SRM application is creating 2 idocs to send to the EPR application. We have just performed an upgrade and this was not happening b

  • WebI/DeskI SIG Discussion Forum

    There is now a discussion area within the WebI/DeskI Special Interest Group of [ASUG|http://www.asug.com]. The ASUG WebI/DeskI SIG a continuation of the original GBN community of Web Intelligence and Desktop Intelligence users. The transition of this

  • Push mail accounts

    Do push mail accounts use a lot less battery since it does not check the email every few minutes like fetch does? Is MobileMe and Yahoo the only email servers that offer push?