Wont leave wait

here's the question:
Create two Thread subclasses, one with a run( ) that starts up and then calls wait( ). The other class's run( ) should capture the reference of the first Thread object. Its run( ) should call notifyAll( ) for the first thread after some number of seconds have passed so that first thread can print a message.
here's my code..
import java.io.IOException;
import java.lang.*;
public class EmsExercise8 {
     public static void main(String[] args) throws Exception {
          new WaitThread("Initializing...").start();
class WaitThread extends Thread{
     WaitThread(String s){
          super(s);
     public void run(){
          System.out.println(getName());
          System.out.println(" ");
          int counter = 3;
          while(counter==3){
               synchronized(this){
              try{
                   wait();
                   new NotifyThread("Start").start();
              }catch(InterruptedException  ex){
               System.out.println("Notified");
               counter++;
class NotifyThread extends Thread{
     public NotifyThread(String a) {
          super(a);
     public void run(){
          System.out.println("Please Notify");
          notifyAll();
my problem is that it doesn't seem to finishing the waiting process and even if it is able to get to the NotifyThread it doesn't come back to the Wait thread.. Help!! pls..!
Message was edited by:
Arch_Bytes

ive switched it and added a snyc block.. this time it skips the wait..
im starting to hate threads.. argh!^_^
thanks in advance!
public class EmsExercise8 {
     public static void main(String[] args) throws Exception {
          WaitThread one = new WaitThread();
          //NotifyThread two = new NotifyThread();
          new NotifyThread(one).start();
class WaitThread extends Thread{
          public void run(){
          System.out.println(getName());
          System.out.println(" ");
          int counter = 3;
          while(counter==3){
               synchronized(this){
              try{
                   wait();
              }catch(InterruptedException  ex){
               System.out.println("Notified");
               counter++;
class NotifyThread extends WaitThread{
     public NotifyThread(WaitThread t) {
     public void run(){
          synchronized(this){
               System.out.println("Please Notify");
               notifyAll();
}

Similar Messages

  • My ipod touch 4th gen wont leave the app when I press the menu button, what do I do? How do i fix it?

    When I use my ipod touch and am trying to leave an app, my ipod wont wont leave unless i keep pressing the menu button. This happens alot during snapchat and my friends ask me why I screenshot so much. And I dont screenshot at all. Why is my ipod doing this? Can it be fixed?

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Restore from backup. See:                                 
    iOS: How to back up           
    - Restore to factory settings/new iOS device.

  • Hey guys on my mac book pro after updating three apps wont leave my dock, when i close them they just re-appear they are "LoginServer", "USBServer" and "NetServer" any ideas to what is the issue?????? PLEASE HELP.

    Hey guys on my mac book pro after updating three apps wont leave my dock, when i close them they just re-appear they are "LoginServer", "USBServer" and "NetServer" any ideas to what is the issue?????? PLEASE HELP.

    Hi I have just got back from the apple store and the guy at the Genius bar looked at it and said it was a manufacturing fault, and because it has been like it since new, and seemed to be getting worse he replaced the computer  and I have a new warranty from today.
    We got the feeling as soon as he looked at it that he has seen this before, I did say to him I was concerned it would be a replacement screen and I was not really happy about that as it was so new, and he said that was the normal procedure, but as the fault was already there at new and it was getting worse they would replace. I could not have asked for a better service.
    Not unpacked this one yet but am hoping all is good, its a great little machine.
    Thank you for your responses, and I hope this might help someone else.  One thing it did not seem to be missing pixels but something to do with the screen production?

  • I was updating my Ipad2 and when it was done it went to the apple logo and wont leave that screen it also will not charge

    I was updating my Ipad2 and when it was done it went to the apple logo and wont leave that screen it also will not charge. Ive tried resetting and it turns off for a second then come right back to the Apple screen.

    Try and force iPad into Recovery Mode:
    1. Turn off iPad. Press and hold the Sleep/Wake button for a few seconds until the red slider appears, slide to turn off.
    2. Connect USB cable to computer; leave the other end alone
    3. Press and hold the Home button down and connect the docking end of cable to iPad
    4. Continue holding the Home button until you see the "Connect To iTune" screen
    5. Release the Home button
    6. Open iTune (make sure you have the newest version of iTune)
    7. You should see "iTunes has detected an iPad in recovery mode"
    8. Use iTune to restore iPad
    Note: You need to be patient and repeat the above many times to recover your iPad

  • HT4623 I tried to update my ipad and it wont leave the apple loading screen

    my Ipad wont leave the the loading screen

    Unable to Update or Restore
    http://support.apple.com/kb/ht4097

  • Iphone wont leave the settings app. cant turn off or return to home. tried connecting to itunes and no change

    tried upgrading to ios7 then said i didnt have enough storage so attempted to delete apps in usage and turned my icloud on, now iphone wont leave the settings app. cant turn off or return to home. tried connecting to itunes and no change. help!

    You need to reset the phone, but that requires a functioning on/off (lock) button.  Time to visit Apple.

  • Just updated my ipad4. now its in recovery mode it wont leave it and even tried that fancy little home and lock screen trick. It is telling me i need to restore. I do not want to because i have not backed up my pictures. HELP!!!!!!!

    just updated my ipad4. now its in recovery mode it wont leave it and even tried that fancy little home and lock screen trick. It is telling me i need to restore. I do not want to because i have not backed up my pictures. HELP!!!!!!!

    It's too late now to worry about not having backed up. You have to restore the iPad or .....
    A. You can have a device that still has all of the photos on it but you can't get to them because the device doesn't work
    or.....
    B. You can restore, lose the photos and have a functioning device again.

  • HT201263 Ipod touch 4thG wont leave apple logo screen.

    I dropped my ipod about a month ago and it worked that same day until the next day. I charge my ipod and the only thing that comes out is the apple logo and thw black screen in the background. I've tried the different pressing buttons and it still wont seem to work. The farthest i can go it where it's just about to update and restore, but then itunes says it fails. HELP pleaseeeee

    Error 1604
    This error is often related to USB timing. Try changing USB ports, using a different dock connector to USB cable, and other available USB troubleshooting steps (troubleshooting USB connections. If you are using a dock, bypass it and connect directly to the white Apple USB dock connector cable. If the issue persists on a known-good computer, the device may need service.
    If the issue is not resolved by USB isolation troubleshooting, and another computer is not available, try these steps to resolve the issue:
    Connect the device to iTunes, confirm that the device is in Recovery Mode. If it's not in Recovery Mode,put it into Recovery Mode.
    Restore and wait for the error.
    When prompted, click OK.
    Close and reopen iTunes while the device remains connected.
    The device should now be recognized in Recovery Mode again.
    Try to restore again.
    If the steps above do not resolve the issue, try restoring using a known-good USB cable, computer, and network connection.
    Error 1600, 1601, 1602
    Follow the steps listed above for Error 1604. This error may also be resolved by disabling, deactivating, or uninstalling third-party security, antivirus, and firewall software. See steps in this article for details on troubleshooting security software.

  • How do i unlock my ipod touch when it wont leave recovery mode?

    My ipod touch will not leave recovery mode, and when I plug it into itunes a window pops up saying i need to unlock my ipod touch before it can sync. I cant do this, because it will not leave recovery mode to let me unlock it. What should i do?

    Try RecBoot to kick it out of Recovery Mode.
    Basic troubleshooting steps  
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD + OCZ Vertex 3 SSD Boot HD 
    Got problems with your Apple iDevice-like iPhone, iPad or iPod touch? Try Troubleshooting 101

  • Jakarta HTTPClient , dont wont to wait for a response.

    Hi there.
    I wonder if I can do that , I want to send a post\get request to another server but I don�t want to wait for a response from it.
    Actually, I want to continue with my program regardless to the response and don�t want to be delayed while waiting.
    How can I do it?
    Hope I made myself clear, thanks.
    Shlomi

    spawn a Thread that will send the request. When it's time to process the response, check the Thread to see if any response was returned from the server.
    example
    public class MyThread extends Thread{
        private String response = null;
        private int status = 0;
        private boolean complete = false;
        public void run(){
             // TODO: et the response from the server
             // set the response and status and complete (synchronize all variable when doing this)
        public boolean isComplete(){
            return complete;
        public String getStatus(){ return status; }
        public String getResponse(){ return response; }
    public class Demo(){
        public static void main(String args[]){
            // do some work
            MyThread thread = new MyThread();
            thread.start();
            // do some more work (don't wait for server response
            // now it's time to get the response
            while (!thread.isComplete()){
                try{   Thread.sleep(1000); } // sleep for 1 second
                catch (Exception e){ }
            String response = thread.getResponse();

  • My ipod 5 wont leave recovery mode at all no matter what i do !

    My iPod touch 5th generation is stuck on recovery mode. i tried everything
    first i tried to restore it and it wont sync my iPod
    second i held my ipod home button and lock button for 10 seconds like other people told me it still wont work
    third i took it to my buddies that is really good with apple products and he doesn't even know
    Its really making me upset with apple -.-
    Please Help Me Out!

    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try on another computer
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       

  • HT1338 disk wont eject from my macbook pro and black screen with white letter text wont leave.

    disk wont eject from my macbook pro. Displays black screen with white text. How do I remove or move on?

    It sounds like you've experienced a "kernel panic".
    This thread has some advice on how to deal with one.
    If you need more advice, please explain what you mean by "disk won't eject from my macbook pro".

  • TS3274 ipad wont leave setting screen. even if i push power button it wont leave setting screen

    omy ipad is stuck in the settings. i pushed the circle button at the bottom but nothing. i pushed the pwer button but still nothing. ipad will not leave settings screen. i can still scroll up and down and pick any of the option on the setting screen, just cant leave the settings.

    Reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.

  • How can I unlock my ipad when it wont leave my storage  setting showing  low to back up

    Hi My ipad 3 wont let me in it keeps showing storage on icloud is low and its not backed up I cannot get off this. Please help.

    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • HELP HELP HELP battery lighting bolt wont leave

    Please refer to this post
    http://forums.ipodlounge.com/showthread.php?s=&postid=715239#post715239
    And this apple help page.
    https://swdlp.apple.com/cgi-bin/WebObjects/SoftwareDownloadApp.woa/309/wo/dQAawa uPVKq9dzR7GdbRp0/2.1
    Ps. could it be a faulty battery which worked for about a week, died (my fault) now WONT CHARGE
    Anyone can help.
    If you ask
    yes, I restarted my computer
    yes, I restarted I tunes
    yes, I re installed i pod software
    no my computer wont recognize i pod
    no, i tunes wont reecognize i pod
    no, update sofwtare wont regonxize (therefore i cant restore)
    Thanks very much for any assistance

    At Ease .. Young One . Patience is th only solution to your problem . What your facing is a Flash Drive Skip > Minor problem I'd Say. What your gonna do is an Ipod Reset.
    Steps for an IPOD Reset:
    Toggle the Hold switch on and off. (Slide it to Hold, then turn it off again.)
    Press and hold the Menu and Select buttons until the Apple logo appears, about 6 to 10 seconds. You may need to repeat this step.
    Tip: If you are having difficulty resetting your iPod, set it on a flat surface. Make sure the finger pressing the Select button is not touching any part of the click wheel. Also make sure that you are pressing the Menu button toward the outside of the click wheel, and not near the center.
    If the above steps did not work, try connecting iPod to a power adapter and plug the power adapter into an electrical outlet, or connect iPod to your computer. Make sure the computer is turned on and isn't set to go to sleep.
    After that get the latest IPOD updater Software (from Ipod Site )and LOad it on to your Computer.
    It should work like clock work from there.

Maybe you are looking for