Start from beginning in a Thread

Hello!
I have some problem of starting a Thread again when I have stoped it. The thing I want is that I want to start a Thread, then stop it and after that start the Thread from begining, and I can not use resume/suspend because the Thread should need to begin just after run. For example
Class hello extends Thread
     run()
          // do something....
     main
          hello h=new hello();
          while(1>0)
          if(.....)
          h.start();
          if(.......)
          h.stop()
Because of the while these if can happen many times and h will be stopped and started many times. But after I have stoped it once then when I try to start it, it wont start.
I have solved this problem by making new Threads like h, h1, h2..... all the time but is there a way to do this with only one name of the Thread. And that when it is started then it should start from the beginning of the run.
Regards
Tomas

Don't use stop():
It was deprecated.
"This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath exception propagating up the stack). If any of the objects previously protected by these monitors were in an inconsistent state, the damaged objects become visible to other threads, potentially resulting in arbitrary behavior. Many uses of stop should be replaced by code that simply modifies some variable to indicate that the target thread should stop running. The target thread should check this variable regularly, and return from its run method in an orderly fashion if the variable indicates that it is to stop running. If the target thread waits for long periods (on a condition variable, for example), the interrupt method should be used to interrupt the wait."
You can use wait() and notifyAll() inside synchronized block.

Similar Messages

  • Can't download mountain lion from app store, shows error message: retry/cancel and starts from begining

    can't download mountain lion from app store, shows error message: retry/cancel and starts from begining,
    I alreasy paid for it
    Can I get a direct download link other than from app store

    Try opening the Terminal utility in your system and running the following command to open the system's caches folder:
    open $TMPDIR../C
    Then locate and remove the folder called "com.apple.appstore" and then try relaunching the App Store and downloading the installer again.

  • Mountain lion download is very slow and in-between it hangs of and starts from beginning. Is there a solution i have already purchased it can i download a torrent and authorize it

    Mountain lion download is very slow and in-between it hangs of and starts from beginning. Is there a solution I have already purchased it can I download a torrent and authorize it. Somebody pl. Help

    Exactly. Some of us don't understand the situation in India. This is a country with sickest internet speeds. The internet segment is dominated by fraudulant companies. There is no consistency that is why most of the data transfer here is through Pen drives and torrent websites. We have never seen a good downlooad speed here. And on the top of inconsistency lies the Mac book Air without a built in RJ45 port.
    If i have to do it in an internet cafe it will cost me more time and money than to purchase a Mac book air itself. Apple should start giving us software loaded flash drives at least at premium.

  • MLB on Apple TV not starting from beginning of live game when Play is pressed

    I have an Apple TV 2nd Generation and have been using the MLB.tv app.
    Only compalint:  When I select a game, Apple TV tells be to press Select to play live and Play to start from the beginning.
    However, when I press play or select, I am taken to the live game, which is a drag.
    Anyone experiencing the same problem?

    Hi christoph, this is one of those headbangers.
    the AAC and mpeg or exported as mp3 files both do it, which yes, is totally weird.
    So, i can get the context menu, right clicking or cntl click, but what option is there to set it to new, as you suggest.
    Thanks for your efforts
    :)c
    Hey, brother
    I just got the solution in another forum. fascinating.
    see the link http://forums.macrumors.com/showthread.php?p=7191871#post7191871
    its about the "remember playback position" checked in the individual track options in track info.
    Nice one.
    Auf Wiedersehn.

  • [Bug] Playing stream audio from the editor almost always starts from beginning.

    Whenever I am creating a movie clip with an audio layer set to "stream" I usually click certain points of the movie and hit enter to see and hear it. In Flash CC however, it seems about 95% of the time no matter what frame I am on when I hit enter the audio starts from the beginning and is not in sync. There have been a few cases in which the audio started at right frame but I haven't yet been able to isolate the process. Audio works great in the exported SWF, this issue is just just with the editor.

    This bug still hasn't been fixed. I don't recommend Flash for any animator; the issue makes syncing to music and vocals extremely frustrating. This bug has been around for months without solution.
    Running as administrator does not solve the problem.
    You will have the audio bug even if you do not have a Beats Audio Soundcard.
    The longer and more complicated your project, the more frequently the bug happens. When it first begins (around 15-30 seconds worth of frames and about 7 layers) you can make the audio stream as it should by clicking your audio track, setting it to "stop," saving your project, and setting the audio to "stream" again.
    However, when you have about 60 seconds on your timeline, the bug happens a lot more, and you have to actually close the project to get the sound to work again if you do not have the patience to wait for it to fix itself. The wait ranges from 30 seconds to several minutes to never fixed until you close. It's highly unpredicatable. Sometimes it is not enough to close the project, in which case you must quit Flash and start it up again.
    It happens with both mp3 and wav sounds.
    After a month of this bug, I still can't pinpoint what causes it. It's completely random.
    This post suggests it has something to do with scrubbing the timeline. I haven't been able to replicate the bug by doing this. It happens whether or not you use the slider or just click on frames to navigate.
    My system specs:
    Windows 7 Home Premium (Service Pack 1)
    64-bit operating system
    Processor: Intel i5-4670K CPU @3.40 GHz
    RAM: 8 GB
    NVIDIA GeForce GTX 660 Graphics Card
    Audio is also NVIDIA High Definition Audio
    The bug happens even if I plug in headphones to a regular audio port not on the graphics card.
    Other audio types I have are the Intel Display Audio and Realtek High Definition Audio. I've tried messing with audio settings to no avail.

  • Flash CC "stream" mp3 clip starts from beginning, regardless of current frame

    I have an mp3 set to "stream", it's 25.7 seconds long, 41.1k, 16-bit, mono. "Stream" works fine when I scrub through the timeline by mouse, but during playback, the clip always start from the beginning, so it is out of sync unless I start from the first frame. How can I fix this? It makes the program much less usable for lip-sync.

    I do see a bug logged internally for this. However since this is inconsistent repro, it will be great if you can PM me the test file that shows this problem.
    -Sujai

  • ITunes U forgets where I stop last time, and always starts from beginning of the audio/video

     

    This bug still hasn't been fixed. I don't recommend Flash for any animator; the issue makes syncing to music and vocals extremely frustrating. This bug has been around for months without solution.
    Running as administrator does not solve the problem.
    You will have the audio bug even if you do not have a Beats Audio Soundcard.
    The longer and more complicated your project, the more frequently the bug happens. When it first begins (around 15-30 seconds worth of frames and about 7 layers) you can make the audio stream as it should by clicking your audio track, setting it to "stop," saving your project, and setting the audio to "stream" again.
    However, when you have about 60 seconds on your timeline, the bug happens a lot more, and you have to actually close the project to get the sound to work again if you do not have the patience to wait for it to fix itself. The wait ranges from 30 seconds to several minutes to never fixed until you close. It's highly unpredicatable. Sometimes it is not enough to close the project, in which case you must quit Flash and start it up again.
    It happens with both mp3 and wav sounds.
    After a month of this bug, I still can't pinpoint what causes it. It's completely random.
    This post suggests it has something to do with scrubbing the timeline. I haven't been able to replicate the bug by doing this. It happens whether or not you use the slider or just click on frames to navigate.
    My system specs:
    Windows 7 Home Premium (Service Pack 1)
    64-bit operating system
    Processor: Intel i5-4670K CPU @3.40 GHz
    RAM: 8 GB
    NVIDIA GeForce GTX 660 Graphics Card
    Audio is also NVIDIA High Definition Audio
    The bug happens even if I plug in headphones to a regular audio port not on the graphics card.
    Other audio types I have are the Intel Display Audio and Realtek High Definition Audio. I've tried messing with audio settings to no avail.

  • Exported audio tracks are not starting from beginning of track

    I have GB '08.
    I export recorded podcasts (i actually make language learning CDs using an external mic) so each track ends up at between 20 sec or say 2 mins, to an Itunes playlist. I may play a track, and then click on another, by double clicking as is usual in itunes to start a new track, EXCEPT that it starts the new track at the place it was last time when it was played, even if it is its first time played in itunes, but was listened to some point whilst in garage band.
    so the tracks dont start at the beginning of the track but rather where they were left off when last listened too. This happens also on my ipod with those tracks and i have to manually drag a track's progress bar back to the beginning to hear it from its start.
    This is a disaster for my product. Is it a bug or is it a setting? Please help urgently.
    Many thanks, Craig

    Hi christoph, this is one of those headbangers.
    the AAC and mpeg or exported as mp3 files both do it, which yes, is totally weird.
    So, i can get the context menu, right clicking or cntl click, but what option is there to set it to new, as you suggest.
    Thanks for your efforts
    :)c
    Hey, brother
    I just got the solution in another forum. fascinating.
    see the link http://forums.macrumors.com/showthread.php?p=7191871#post7191871
    its about the "remember playback position" checked in the individual track options in track info.
    Nice one.
    Auf Wiedersehn.

  • Audio will start from beginning midway?

    When I put a video into the project area and then drag into the Sequence the video will start to play normally and the audio is in sync. But for some reason at 3 minutes and 43 seconds, the audio will jump all the way back to the beginning but it will still show that it is playing the same track. I have played the video in regular windows media player and there is no issue, it only happens in Premiere. Does anyone have any idea how to fix this? I've tried recreating new sequences from the clip and it keeps happening... thanks for any help!

    I have this problem as well but it is intermittent. Sometimes it restarts where I ended. I can not figure out what is different between the situations though. It seems that this must just be a bug in the software. Hopefully it will get fixed because, I agree, it is terribly annoying. I've learned to use the screenshot function to capture my position.

  • How to make Percentage start from zero in SSRS Report?

    Hi,
    I am new to SSRS Reporting. I have developed a small report which has percentage in it.
    My Report snapshot as below
    I want the percentage(orange line) to start from begining(from zero). As of now it starts from Feb, 2014. What am i suppossed to do to achieve this??
    Regards, Shreyas R S

    Hi Shreyas R S,
    Based on my research, it seems that the Percentage line is a line chart. In this scenario, the line should be started from the first value to the last value in the X-Axis. This is by design. If the percentage line is a horizontal line, we can use a StripLine
    to simulate it. For more details, please see:
    Click the Primary Vertical Axis and click the StripLines option in the Properties pane.
    Add a new member, select a color (Orange) for BackgroundColor item.
    In the Interval category, set a value (17) as the IntervalOffset and set the StripWidth to 0.5 to widen the line.
    To hide the original percentage line, we can right-click the percentage field to open the Series Properties dialog box, then type: =noting in the Value field in the Values pane.
    The following screenshot is for your reference:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support

  • AudioInputStream won't start from the beginning

    I'm not sure if this is normal or not, but here's a weird the situation. I have a number of audio files that I play together. Nothing complicated.
        public void playAudio() {
            try{
                File soundFile_1 = new File("SoundFile1.wav");
                File soundFile_2 = new File("SoundFile2.wav");
                File soundFile_3 = new File("SoundFile3.wav");
                audioInputStream_1 = AudioSystem.getAudioInputStream(soundFile_1);
                audioInputStream_2 = AudioSystem.getAudioInputStream(soundFile_2);
                audioInputStream_3 = AudioSystem.getAudioInputStream(soundFile_3);
                audioFormat_1 = audioInputStream_1.getFormat();
                audioFormat_2 = audioInputStream_2.getFormat();
                audioFormat_3 = audioInputStream_3.getFormat();
                DataLine.Info dataLineInfo_1 = new DataLine.Info(SourceDataLine.class,audioFormat_1);
                DataLine.Info dataLineInfo_2 = new DataLine.Info(SourceDataLine.class,audioFormat_2);
                DataLine.Info dataLineInfo_3 = new DataLine.Info(SourceDataLine.class,audioFormat_3);
                sourceDataLine_1 = (SourceDataLine) AudioSystem.getLine(dataLineInfo_1);
                sourceDataLine_2 = (SourceDataLine) AudioSystem.getLine(dataLineInfo_2);
                sourceDataLine_3 = (SourceDataLine) AudioSystem.getLine(dataLineInfo_3);
                new PlayThread().start();
            } catch (Exception e) {
                e.printStackTrace();
                System.exit(0);
        class PlayThread extends Thread{
            byte tempBuffer_1[] = new byte[100000];
            byte tempBuffer_2[] = new byte[100000];
            byte tempBuffer_3[] = new byte[100000];
            @Override
            public void run(){
                try{
                    sourceDataLine_1.open(audioFormat_1);
                    sourceDataLine_2.open(audioFormat_2);
                    sourceDataLine_3.open(audioFormat_3);
                    sourceDataLine_1.start();
                    sourceDataLine_2.start();
                    sourceDataLine_3.start();
                    int nBytesRead;
                    while(((nBytesRead = audioInputStream_1.read(tempBuffer_1,0,tempBuffer_1.length)) != -1) &&
                          ((nBytesRead = audioInputStream_2.read(tempBuffer_2,0,tempBuffer_2.length)) != -1) &&
                          ((nBytesRead = audioInputStream_3.read(tempBuffer_3,0,tempBuffer_3.length)) != -1) &&
                          (stopPlayback == false)) {
                        if(nBytesRead > 0){
                            sourceDataLine_1.write(tempBuffer_1, 0, nBytesRead);
                            sourceDataLine_2.write(tempBuffer_2, 0, nBytesRead);
                            sourceDataLine_3.write(tempBuffer_3, 0, nBytesRead);
                    sourceDataLine_1.drain();
                    sourceDataLine_2.drain();
                    sourceDataLine_3.drain();
                    sourceDataLine_1.close();
                    sourceDataLine_2.close();
                    sourceDataLine_3.close();
                    stopPlayback = false;
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(0);
        }I also have a method that combines the three audio files into one. I usually call this method after having played the files for a short time.
        public void saveAudio() {
            saveList.add(audioInputStream_1);
            saveList.add(audioInputStream_2);
            saveList.add(audioInputStream_3);
            saveMixAIS = new MixingFloatAudioInputStream(audioFormat_1, saveList);
            File saveFile = new File("SaveMix.wav");
            try {
                AudioSystem.write(saveMixAIS, AudioFileFormat.Type.WAVE, saveFile);
         } catch (IOException e) {
                e.printStackTrace();
    } Interesting enough, this code doesn't seem to combine the three audio files properly. What seems to happen is that the combined file starts at the location where I stopped playing. In order to get the files to start from the very beginning, I need to re-initialize the AudioInputStream.
        public void saveAudio() {
            try{
                File soundFile_1 = new File("SoundFile1.wav");
                File soundFile_2 = new File("SoundFile2.wav");
                File soundFile_3 = new File("SoundFile3.wav");
                audioInputStream_1 = AudioSystem.getAudioInputStream(soundFile_1);
                audioInputStream_2 = AudioSystem.getAudioInputStream(soundFile_2);
                audioInputStream_3 = AudioSystem.getAudioInputStream(soundFile_3);
            } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(0);
            saveList.add(audioInputStream_1);
            saveList.add(audioInputStream_2);
            saveList.add(audioInputStream_3);
            saveMixAIS = new MixingFloatAudioInputStream(audioFormat_1, saveList);
            File saveFile = new File("SaveMix.wav");
            try {
                AudioSystem.write(saveMixAIS, AudioFileFormat.Type.WAVE, saveFile);
         } catch (IOException e) {
                e.printStackTrace();
    } Is this normal?

    mohogany wrote:
    That definitely makes sense.
    I was under the impression that the AudioInputStream never loses the data it has read and that the AudioSystem.write method always starts from the beginning of this AudioInputStream. I need to stop treating the AudioInputStream like an array and instead treat it more like fresh water.Definately.
    AudioInputStream doesn't actually have anything in it...it's actually just a wrapper. Whenever you call read on it, it just reads whatever it's wrapping around, and returns the result. This is why it can contain both live data being recorded or file data or a network stream or...
    In this case, it is reading from a BinaryFile. Everytime you call read, it increments the file position... and it doesn't reset the file position when you call AudioSystem.write...

  • Is there a way to view earlier messages in a thread without going through each day? Also, can you make a photo album from the same text thread without going back to the beginning?

    Is there a way to view earlier messages in a thread without going through each day? Also, can you make a photo album from the same text thread without going back to the beginning?

    Turn Settings > General > Accessibility > Zoom to ON.

  • Can I download a file in different sessions or should it be in a single session? In other words can I pause the download of a file, shutdown/restart my system and then resume download from where I left off? Or will it start from the very beginning?

    Can I download a file in different sessions or should it be in a single session? In other words can I pause the download of a file, shutdown/restart my system and then resume download from where I left off? Or will it start from the very beginning?

    If a server supports resuming downloads then the download should continue where it left off.<br />
    You can test that by simple starting a large download and wait a minute or so before pausing it.<br />
    Then you can close and restart Firefox and see if resuming works.
    You can set the pref browser.download.manager.quitBehavior to 2 on the about:config page.<br />
    That will make Firefox ask for confirmation if you want to cancel the download if you close Firefox.
    See:
    * http://kb.mozillazine.org/browser.download.manager.quitBehavior

  • Keynote kept crashing.  Won't start from the beginning.  Help!

    The keynote kept crashing.  I went to the website just now, but when I try to watch, I can't get back to the beginning, which I missed.  The only options are "watch live" and "start from pause," and neither of those is what I need to do.

    As we can't see what your doing, provide some details,  what website is this, did you create the file, is it a Keynote or Quicklime or PDF file?

  • Of clans but due to shortage of space i want to delete it for some days.If i delete the app and then reinstall it after a month should i start from the beginning or cont. from where i left

    i use ipad mini with retina display 16gb i love playing clash of clans but due to shortage of space i want to delete it for some days.If i delete the app and then reinstall it after a month should i start from the beginning or cont. from where i left

    However, I originally had the kindle app on there and when he is reinstalling it comes up with my kindle account. How do we change this?
    OPen teh Kindle app.
    Tap the i at bottom right then Settings > Deregister this device.
    -> http://www.amazon.com/gp/help/customer/display.html?nodeId=200375710&#managedevi ces
    He does not have an actual kindle so I am not sure if he would be able to create one anyways.
    The Kindle app is so you do not have to use a Kindle. Yes, he can have a Kindle account and not own an actual Kindle hardware device.

Maybe you are looking for

  • IPhone 4S Clean ITunes Install of 8.1...Others Experiences?

    Greetings all! A number of my Apps on my 4S have been upgraded to a point they will not update on my 4S. I did a clean install of the most recent IOS version using ITunes on my IPad2 and while performance is better than the initial upgrade it is stil

  • Head Office account in FBL5N

    Hi there! We have an head office account. When we viewed it in FBL5N with the following paramters: Customer, Company code and Open item as of xx.xx.xxxx. The result of which for example is 50000USD. Then we tried to use FBL5N but with different param

  • PrintJob background color

    Hi... I have an SWF that has a print function attached to a button that prints a movie clip called content_MC. I have the SWF set with a transparent background using the wmode=transparent in the embed object. The FLA/SWF has a white stage/background.

  • IPhone  does not appear in list of devices in iTunes in the cloud

    my iPhone does not appear in the list of devices

  • Will Apple release any iOS6 Guided Access video tutorials?

    Hi, I am a Developmental Therapist that uses the iPad with families affected by autism and sensory processing disorder. After exploring many features this morning, I think families and individuals affected by disability really need a series of video