Is it guaranteed that a started thread will run until the end?

Hi guys,.

Someone wrote this on the threads:

«Thread depends on the VM Scheduler and * it has NOT guaranteed a Thread run and selection by the Scheduler of VM despite you started the thread with a call to x.start () *.» "When you started the Thread it is only in a RUNNABLE STATE, re-read Chapter until you have understood" (Chapter 9 wire - Sun Certified program for Java 6 - Study Guide (310-065) - Kathy Sierra and Bert Bates - 2008)

It's the Red sentence that make me really confused. In fact, I read this chapter several times, and I couldn't read that kind of statement in the chapter. What I have read is the following,

Excerpt from the book (pp. 713-714)

class NameRunnable implements Runnable {}
public void run() {}
for (int x = 1; x < = 3; x ++) {}
System.out.println ("Run by")
+ Thread.currentThread () .getName)
+ ", x is"+ x); ".
}
}
}

public class ManyNames {}
Public Shared Sub main (String [] args) {}
Make an executable
NameRunnable nr = new NameRunnable();
A thread = new Thread (nr);
Put on two = new Thread (nr);
Thread three = new Thread (nr);
one.setName("Fred");
two.setName("Lucy");
three.setName("Ricky");
One.Start ();
Two.Start ();
Three.Start ();
}
}


And the authors wrote this:

Nothing is guaranteed in the previous code EXCEPT this:

Each thread will start and each thread runs until the end.

I try to explain to me, what I heard in the sentence in the book: "each thread will begin, and each thread runs until the end."

$java ManyNames

After this call, the main method of the class that manynames is called and the JVM running the code in this sequential method. When the main thread calls one.start (), the thread (thread Java) is mapped to an operating system thread (well well, in most implementations), but the important thing, the (Java thread) thread gets the RUNNABLE state pending to have a chance to get the State RUNNING one start execution of the its Runnable target run() method. So, at this point, we have two sons who may be selected to get the State of EXECUTION, the main thread and the thread one. Assume the main thread runs a hand through method. In this case, calls two.start () and three.start () are called. Main thread ends, and we have three threads alive, waiting for his ride to get the condition of OPERATION. For me to run in full means that all these discussions will be printed three times the sentence:

"Managed by [NAME of THREAD: Fred or Lucy and Ricky], x is [1, 2, or 3].

And each of them will end their run() (AS THE CODE MEANS) method. A possible output might be:
Directed by Fred, x is 1
Managed by Lucy, x is 1
Managed by Lucy, x is 2
Directed by Fred, x is 2
Managed by Lucy, x is 3
Directed by Fred, x is 3
Managed by Ricky, x is 1
Is managed by Ricky, x 2
Managed by Ricky, x is 3

But this order is not guaranteed.

So, my question is simple, if we execute THE CODE (without everything changed) in ANY Machine Java virtual, it is GUARANTEED all started threads (main thread, Fred, Lucy and Ricky) will run until the end OR I have to believe what the guy wrote to me: it has NOT guaranteed a Thread run and selection by the Scheduler of VM despite you started the thread with a call to x.start ()?

If what this guy says is correct, it should be to create and start a thread if it is not guaranteed that this thread will run until the end? Well, if it is a nice Visual clock on the screen it does not matter if we can see the clock or not, but what would you say if it is a wire that control the process of emergency in a factory, just an example.


Thanks for your opinions,

Alvaro

Published by: Alvaro on July 28, 2011 17:15

While there is no guarantee, the goal of starting discussions is that it will run until the end, and this is what happens under normal conditions.

Tags: Java

Similar Questions

  • How to ensure the backup of Windows 7 starts and runs until the end on a laptop which is mode standby, or could be put in mode 'sleep' when the lid is closed.

    Hello

    Many of us with laptops with Windows 7 would like to ensure that, when a Windows backup is scheduled, it starts successfully and goes to full completion, regardless of whether the phone is first 'sleep', or if the user of the laptop close the lid of the laptop, which would normally the laptop mode 'sleep'.  In other words, how to backup Windows or Windows 7 be configured to wake from mode "sleep" and prevent it from sleep mode, when a backup is scheduled and actively running?

    I saw a way to schedule a task that will wake the computer, but I'm looking for something more intelligent than that.  I'm looking to see if Microsoft has already thought this through and allow you to pre-configure operating system such as we have no additional installation software.

    Thank you

    Dave

    We continued this thread in http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/how-do-i-keep-windows-7-from-sleeping-in-the/9602fbe6-f9d2-461d-88ee-710369e6f543

  • As that I start my computer I get the error message "Rundll: error loading C:\windows\idoroyuyevev.dll the specified module could not be found." How should I do?

    Original title: Rundll error help

    As that I start my computer I get the error message "Rundll: error loading C:\windows\idoroyuyevev.dll the specified module could not be found." -What it means and how to fix it?

    It is sometimes easy to get rid of the error message by doing something like disable the startup item in msconfig (if you can still find), but I suggest you fix the problem and difficulty not only the symptom of the problem by simply deleting the startup message.
    I would also not recommend you start digging in the registry to try to find the startup item and remove it unless you have a backup of your system or at least a backup of your registry, because there is no 'Cancel' or 'quit without saving changes' option in regedit.  If you make a mistake, that's all.
    These ideas relieve 'rapid' and sometimes risky of the symptom if they not even work at all, but they can't actually solve the problem.  Also, I'd be suspicious of ideas that begin with the words "try."  You don't need to try things, you need to fix things.  You don't need to try ideas that might work, you must do something that will always work all the time.
    Here are the detailed instructions that protect you and solve your problem in the 'right' way.
    There is very little. DLL files that should be loaded from the C:\WINDOWS folder and is not one of them.  If you do not have a good explanation for the name of the file in a Google search, the chances are good that your system is currently or has been infected by malware.
    A "Cannot find...". ', ' Failed to start..., "Could not load..." ». "Might not work... "" Cannot run ""error loading... ". "or"specific module could not be found"message at startup is usually related to the malware that has been configured to run at startup, but the referenced file has been removed after a malware scan, leaving behind him a startup item or the registry entry pointing to a file that does not exist.
    It might be a removal of malicious software or an application not installed.  The entry may have a curious looking name since it was probably generated at random when the malware was installed. If you search your system for the referenced file, you may not find.
    Windows attempts to load this file but cannot locate because the file has been deleted for most probably during an analysis of the malware. However, an orphaned associate of remainders of startup parameter or registry entry and tells Windows to load the file when you start or connection.
    So you should delete the referenced entry Windows stop trying to load or run the file. It may or may not be included in the registry, but you can find it.  Autoruns (see below) you get the elements no matter where it is.

    You must be sure to solve the problem and not just fix the symptom of the problem by simply relieving your message - system is not a fix (there is a difference).

    If you just locate and uncheck the item in msconfig, which disables the element but does not remove the reference to the element of false starting your computer.   The msconfig program is not a Startup Manager, that's a troubleshooting tool.  Disabling things in msconfig to put an end to the messages and think that your problem is solved is short-sighted and leave behind him a sloppy XP configuration.  Just disable the display of a start-up error message should not count as a 'solution' to the problem.
    If you are comfortable editing the registry, you can find and remove the reference directly from there or remove it using a popular third-party tool called Autoruns.  The problem can always be found in the registry well.
    Before making any changes to your registry by hand or with third-party tools, don't forget to first make a backup of the registry
    . There is no cancellation or exit without saving the option in regedit.
    Here is a link to a popular registry backup tool:
    You can also use the Autoruns to find the element of start remains little matter where he's hiding.  Autoruns does not install anything on your computer.  It will display all startup locations where the reference may be then you can turn it off or remove it completely.  Here is the download link for Autoruns:
    Run Autoruns.exe and wait that he at the end of the filling of the list of entries.
    When the Autoruns is finished scanning your system, it will say "Ready" in the lower left corner.  Autoruns can be a little intimidating to first if you have never seen it before because it displays a lot of information.  You are really interested only a few sections.
    The problem is usually to start the system or the user startup entries, then click the connection tab and see if the startup item is there.
    Scroll through the list and look for a boot entry associated files in the error message.
    If you can't find on the connection tab, look in any tab.
    You can also click file, search to search for logon, or any tab for all or part of the name of the element.
    Right-click on the offending entry and choose Remove.  If you are not sure what it is, you can just turn it off, restart and if the problem is resolved and things are functioning normally and everything works fine, then remove the offending entry.  If you don't see it in Autoruns, you may edit the registry and remove the item from your startup folder it.  Autoruns shall display the same information however.
    Given that your system has or has had an infection, follow up with this:
    Perform scans for malware, and then fix any problems:
    Download, install, update and do a full scan with these free malware detection programs at:
    Malwarebytes (MMFA): http://malwarebytes.org/
    SUPERAntiSpyware: (SAS): http://www.superantispyware.com/
    They can be uninstalled later if you wish.
    Restart your computer and solve the outstanding issues.
  • How can you cancel the download of an update that was started by after having pressed the button "Check for Updates" in the window "On Firefox", please?

    How can you cancel the download of an update that was started by after having pressed the button "Check for Updates" in the window "On Firefox", please? If possible, please cover all platforms, Mac, Windows, Linux, although the first mentioned is what currently applies to my situation.

    Thank you.

    Such a download is usually recorded in a updates or updates folder in the program folder or the Firefox application.
    You can delete this folder to cancel the download.

    If the files have already been downloaded, then delete the files in the folder updates\0 and updates.

    Mac: /Applications/Firefox.app/updates "/path_to/Firefox.app/Updated.app"
    Linux: "/path_to/firefox/updated"
    Windows: C:\Users\<user>\AppData\Local\Mozilla\Firefox\Mozilla Firefox\updates
    
  • Disk Defragmenter has detected that Chkdsk is scheduled to run on the Volume: C:. Please run Chkdsk /f.

    I know this question has been asked several times, but I did these steps and still not get Defragmenter to work.  My Disk Doctor said I don't have problems with my Defragler work program - but I don't have a C: drive not 'dirty '.  I have Windows XP Home Edition and do not know how to run an XP Recovery Console.  Y at - it an easy way just to get the Defragmenter to work?... when I run Chkdsk... It goes through stages and then closes and the problem is still there.  Defragmenter just stopped working, my computer everything works fine.  Help, please.

    Hmmm...  It should only take a few minutes for ImgBurn to create the bootable XP Recovery Console CD, then maybe one of the songs that you have downloaded (xp_rec_con.iso or install IgmBurn) won't quite right.

    You want ImgBurn to play a happy tune when it is successful and a "Oh no!" message when it fails, but it shouldn't take hours to burn this ISO file bit.  You can try another system.  You can always uninstall ImgBurn when finished.

    I say 'be patient' when you run the chkdsk /r command because sometimes it seems to be stuck (or even go back), but it should end later.  Depending on the volume size, the amount of data on the volume, the speed of your system and what the chkdsk finds to do, you can watch several hours.

    Look at these words from the mouth of Microsoft:

    If you use chkdsk /f on a drive or drives for very large (for example, 70 gigabytes) with a very large number of files (for example, millions of files), chkdsk may take a long time (for example, over several days) to complete. The computer is not available during this time because chkdsk does not relinquish control until it is completed.

    At the time of this writing, I'm guessing a disc 70 GB was "very large" but it is quite modest by today's standards.

    Now with today's technology, it is unlikely to take days, but it could still take some time!  If your HARD drive is afflicted with a problem material and dying, it can never finish or be unable to fix things.

    To start XP, it automatically checks each volume to see if it is dirty and will try to run chkdsk from the afflicted volumes.  Sometimes, it's good enough to clear the dirty bit, sometimes it isn't.  You will see a message at startup if the volume should be checked for consistency and XP will do the best.

    That's exactly what the message tells you:

    Disk Defragmenter has detected that Chkdsk is scheduled to run on the volume: (c :))

    You can query the dirty bit on a volume from the command prompt window.

    Click Start, run and enter in the box:

    cmd

    Click OK to open the command prompt window.

    To query the bit of impurity on drive C, type:

    fsutil dirty query C:

    The sample output:
    Volume c is dirty
    Volume C: is dirty

    Type "exit" to close the command prompt window.

    If you are suspicious of your HARD drive and think it might be failing, now would be a good time to backup your personal data (documents, pictures, music, etc.) to an external location - a separate attached USB drive or a few clouds on the Internet.

  • Message ' Disk Defragmenter has detected that chkdsk is scheduled to run on the evolving: (c) "when I click on either analyze or defragment.»»

    Original title: Disk Defragmenter

    When I click on either analyze or defragment a window appears to indicate that, Disk Defragmenter has detected that chkdsk is scheduled to run on the evolving: (c).

    Please run chkdsk/f. My PC is XP service pack 3 - Pro

    Please tell us the next step that allowed me to start my disk defragmentation. Thank you.

    Hello

    -Did you do changes on the computer before this problem?
     
    I suggest you to follow the steps from the link and check if it helps.
    How to defragment your disk Volumes in Windows XP?
     
    For reference:
    How to analyze and defragment a Windows XP disk?
     
    Hope this information helps.
  • Disk Defragmenter has detected that Chkdsk is scheduled to run on the volume HP_Pavillion (C). Please run Chkdsk /f

    When I try to defragment my hard drive a message comes up saying

    Original title: defragment my hard drive

    "Disk Defragmenter has detected that Chkdsk is scheduled to run on the volume HP_Pavillion (C). Please run Chkdsk /f

    I have no knowledge of this annex, or how to make it work, but I need to remove this message before it will allow me to do a defrag, any ideas?

    Ideas:

    • You have problems with programs
    • Error messages
    • Recent changes to your computer
    • What you have already tried to solve the problem

    When I try to defragment my hard drive a message comes up saying

    "Disk Defragmenter has detected that Chkdsk is scheduled to run on the volume HP_Pavillion (C). Please run Chkdsk /f

    I have no knowledge of this annex, or how to make it work, but I need to remove this message before it will allow me to do a defrag, any ideas?

    Ideas:

    • You have problems with programs
    • Error messages
    • Recent changes to your computer
    • What you have already tried to solve the problem

    Restart the computer and let chkdsk to complete its work.

  • PhotoShop CS2 will run under the new operating system Windows 10?

    PhotoShop CS2 will run under the new operating system Windows 10?

    Photoshop cs2 should work on windows 10 or less, it's here.

    Just be aware that you will not be able to use your original photoshop cs2 that you purchased from adobe, because for photoshop cs2 activation servers have been disabled.

    If you download a version no activation of photoshop cs2 and use the serial number on the download page.

    Activation server stops for Creative Suite 2 and Acrobat 7 product Macromedia

    Error: "Activation Server is not available. CS2, Acrobat 7, pass a hearing 3

  • I need a phone number so that I can cancel my order before the end of the year to the top

    I need a phone number so that I can cancel my order before the end of my term

    Go to http://helpx.adobe.com/contact.html?step=ACOM-XCPF-ECHG-XEPF-FPDF-SEND-AcrobatCom_membersh ip-account-payment and click on the still need help? button.

  • CC in lightroom will run on the Mac operating system OS x 10.8 Cougar?

    CC in lightroom will run on the Mac operating system OS x 10.8 Cougar?

    You didn't mention what version of Lightroom, but nothing 4 room should be no problem. Here is a link to the Lr5 requirements http://www.adobe.com/uk/products/photoshop-lightroom/tech-specs.html

  • Web sites will work after the end of the subscription?

    If I create a website in Muse, it will still work if I need to cancel the subscription at any given time?

    Thank you

    What is a free Business Catalyst site which you are referring you get with your Muse 1 year subscription? If so, then the free site would expire too if you end your subscription to Muse.

    If it is not the site of free BC you have published your site, your BC subscription is charged for separately, and then Muse subscription cancellation would not affect your subscription BC.

    Or if you have published your Muse site to a third party host, this has nothing to do with your subscription to Muse. The site would remain alive until the end of your third party by a subscription.

    Thank you

    Vinayak

  • When I edit a photo, the new copy will open at the end of filmstip

    Lightroom 3.6 windows 7

    sometimes but not always, when I choose edit and lr creates a copy edit tiff file, the new copy will move to the end of the film and sometimes he just stay with the original (which is what I want)

    Why

    Thank you

    At the bottom of the grid, you have defined so far to change sort order. Switch to the time of capture or what you want.

  • My iPod 5th generation does not start (it will stay on the apple logo) and will not be detected by iTunes.

    Last night I tried to turn on my iPod that has not been loaded. I plugged it so that it can start loading. I think the iPod as was the accused, has no need for me to start and should have done by itself. When I pressed the button home to start using it, I noticed it was not on. Then I pressed the power button and then saw he was showing the Apple logo and then it turns off again. I tried pressing the "home" button and the Start button / stop at the same time and the same thing will happen. I also tried connecting to my computer and it did not recognize.

    Try the remaining actines of the:

    - iOS: do not respond or does not light

    -Also try DFU mode recovery mode post-test

    How to put iPod touch / iPhone in DFU "Karthik doodles."

    -If failed and that you cannot completely turn completely the iOS device, leave the battery to drain completely. After loading a hour repeat the foregoing.

    -Try a different cable

    -Try on another computer

    S ' there is still not successful that usually indicates a hardware problem and an appointment at an Apple store Genius Bar is in order.

    Shop Apple Store - Genius Bar

  • DVD starts, stops, will not play the DVD. No icon on the control panel

    I have a HP G72-B66US laptop. A few days back I burned a DVD - RW, since then the DVD will not play a DVD. It starts, then stops. I uninstalled the drive and reinstalled the driver several times, but when I look at the Device Manager the DVD has the top yellow triangle. I can't use a recovery disk because it will not play the disc drive. Can someone help me on this? Thank you. Is there a place I can download a disk drive?

    Thank you

    DRCSaid

    To resolve this problem, remove the affected filter drivers. To do this, follow these steps:

    1. Click Start, type regedit in the Search box, and then click regedit in the programs list.
    2. If you are prompted for an administrator password or a confirmation, type your password, or click continue.
  • is it possible that a single screen will work with the slider and second focus mode

    Hello

    can you please tell me is it possible that a single screen will work with cursor mode and second focus mode.

    Thank you

    Hello

    I don't think that it is possible to change the mode of the development of your application outside of in the config.xml file.

    A custom extension may be able to do this, but I have not seen anyone this yet.

Maybe you are looking for