Why a thread can not be restarted?????

Hi,
I have a thread and I started it by claling thread.start() and some where in my code i want to say thread.start(), which jvm won't allow me to do so... could u please reason me elaborately?????????
Thanks
Sato.

Essentially once a Thread has been started it cannot be started again regardless of its current running state.
Calling start on a started Thread makes no sense. Neither does calling start on a Thread that has finished make sense although for less obvious reasons.
You can query a Thread to see if it is still active (has been started and not yet completed) via the isAlive() method.
You can then query the Thread you want to start with code like this
if(!myThread.isAlive()) {
    myThread.start();
}This code works fine when the Thread is still running however what happens when the Thread has run to completion?
Well it is often best to offer more complete state information about your Thread class...
class MyThread extends Thread {
    boolean hasRun;
    public MyThread() {
        this.hasRun = false;
    public void start() {
        super.start();
        this.hasRun = true;
    public boolean hasRun() {
        return this.hasRun;
    public void run() {
if(!myThread.isAlive() && !myThread.hasRun()) {
    myThread.start();
}In this way you can not only see if instances of your Thread class are currently active but also if they have completed.
As to the rest of you posters, why pick on him like that? If you don't know the answers then don't post anything.

Similar Messages

  • Can not logout, restart or shutdown

    I have a Mac running 10.5.8. I have seen this on different models as well.
    The user can not logout, restart or shutdown. When those commands are selected in the GUI nothing happens.
    In the past the only way I could fix it was to create a new profile. There must be an easier way. does anyone know which files I should delete instead of having to create a new profile?

    Richard Saunders wrote:
    The user can not logout, restart or shutdown. When those commands are selected in the GUI nothing happens.
    I'd launch the Console utility and look for messages that might explain the cause of the problem. You might find that it's due to a process that refuses to quit.

  • Safari locks up on my macbook air and can not be restarted.

    Safari locks up on my macbook air and can not be restarted.  Doing a reboot gets me back to normal but every time I restart Safari it goes to the locked up page.

    Quit Safari. If it won't quit in the usual way, select
     ▹ Force Quit...
    from the menu bar, then select Safari from the list and press return.
    Relaunch Safari by holding down the shift  key and clicking its icon in the Dock. That will stop the bad page from reloading automatically. From the menu bar, select
    Safari ▹ Preferences... ▹ Privacy ▹ Remove All Website Data
    to get rid of any cookies or other data left by the server.

  • Why my computer can not adjust the volume up and down althought i have had repair once time in a near day . i must waitting for 15days now it's continue

    why my computer can not adjust the volume up and down althought i have had repair once time in a near day . i must waitting for 15days now it's continue

    1. Remove the headphone.
        If you see red light in the headphone port, plug the headphone
        in and out of the port 5 or 6 times to flip the microswitch inside.
        Sound output may be stuck in the digital mode.
    2. Reset PRAM.  http://support.apple.com/kb/PH4405
    3. Reset SMC.     http://support.apple.com/kb/HT3964
        Choose the method for:
        "Resetting SMC on portables with a battery you should not remove on your own".

  • Why the ejb can not pass the complie?

    I just use the work shop to create a simple ejb(SampleEJB.ejb) like:
    package SampleEJB;
    import javax.ejb.*;
    import weblogic.ejb.*;
    * @ejbgen:session
    * ejb-name = "Sample"
    * @ejbgen:jndi-name
    * remote = "ejb.SampleRemoteHome"
    * @ejbgen:file-generation remote-class = "true" remote-class-name = "Sample"
    remote-home = "true" remote-home-name = "SampleHome" local-class = "false" local-class-name
    = "SampleLocal" local-home = "false" local-home-name = "SampleLocalHome"
    public class SampleEJB
    extends GenericSessionBean
    implements SessionBean
    public void ejbCreate() {
    // Your code here
    * @ejbgen:remote-method
    public void Hello(){
              System.out.println("Hello");
    * @ejbgen:remote-method
    public void Hello2(){
              System.out.println("Hello2");
    but when i build it. The compiler give me error:
    ¾¯¸æ: SampleEJB.java:14: ÕÒ²»µ½ JNDI Ãû³Æ¡£
    [Info:] Creating D:\DOCUME~1\Yong\LOCALS~1\Temp\/wlw_SampleEJB_build\SampleEJB\SampleHome.java
    [Info:] Creating D:\DOCUME~1\Yong\LOCALS~1\Temp\/wlw_SampleEJB_build\SampleEJB\Sample.java
    [Info:] Creating D:\DOCUME~1\Yong\LOCALS~1\Temp\/wlw_SampleEJB_build\META-INF\ejb-jar.xml
    [Info:] null [Bean] MAKE CLASS NAME G:SampleHome P:SampleEJB N:SampleHome
    [Info:] null [Bean] MAKE CLASS NAME G:Sample P:SampleEJB N:Sample
    [Info:] Creating D:\DOCUME~1\Yong\LOCALS~1\Temp\/wlw_SampleEJB_build\META-INF\weblogic-ejb-jar.xml
    [Info:] Creating D:\DOCUME~1\Yong\LOCALS~1\Temp\/wlw_SampleEJB_build\ejbgen-build.xml
    SourceLoader roots: 10
    post-ejbgen:
    ¾¯¸æ: EJBGen ok. Compiling...
    Compiling 3 source files to D:\DOCUME~1\Yong\LOCALS~1\Temp\wlw_SampleEJB_build
    ¾¯¸æ: All files compiled. Running ejbc...
    <2004-5-3 ÏÂÎç16ʱ20·Ö17Ãë CST> <Warning> <EJB> <BEA-010212> <The EJB 'Sample(Jar:
    D:\DOCUME~1\Yong\LOCALS~1\Temp\wlw_SampleEJB_build)' contains at least one method
    without an explicit transaction attribute setting. The default transaction attribute
    of Supports will be used for the following methods: remote[Hello2(), Hello()]
    >
    SourceLoader roots: 60
    D:\DOCUME~1\Yong\LOCALS~1\Temp\wlw_SampleEJB_build\SampleEJB\Sample_vngkt3_HomeImpl.java:13:
    cannot resolve symbol
    symbol : class SampleHome
    location: class SampleEJB.SampleEJB
    implements SampleEJB.SampleHome, weblogic.utils.PlatformConstants
    ^
    D:\DOCUME~1\Yong\LOCALS~1\Temp\wlw_SampleEJB_build\SampleEJB\Sample_vngkt3_HomeImpl.java:69:
    cannot resolve symbol
    symbol : class Sample
    location: class SampleEJB.SampleEJB
    public SampleEJB.Sample create ()
    ^
    D:\DOCUME~1\Yong\LOCALS~1\Temp\wlw_SampleEJB_build\SampleEJB\Sample_vngkt3_EOImpl.java:15:
    cannot resolve symbol
    symbol : class Sample
    location: class SampleEJB.SampleEJB
    implements SampleEJB.Sample, weblogic.utils.PlatformConstants
    ^
    D:\DOCUME~1\Yong\LOCALS~1\Temp\wlw_SampleEJB_build\SampleEJB\Sample_vngkt3_HomeImpl.java:73:
    cannot resolve symbol
    symbol : class Sample
    location: class SampleEJB.SampleEJB
    return (SampleEJB.Sample) super.create(md_ejbCreate);
    ^
    4 errors
    ´íÎó: ERROR: Error from ejbc: Compiler failed executable.exec
    ´íÎó: ERROR: ejbc couldn't invoke compiler
    BUILD FAILED
    ´íÎó: ERROR: Error from ejbc: Compiler failed executable.exec
    ´íÎó: ERROR: ejbc couldn't invoke compiler
    Why? who can give me a hand

    I met the same problem. I am a newbie, but why weblogic even can not build a simple startup ejb project?

  • HT4623 why my ipphone can not be activated when I updated to IS06? My iphone is 3gs and original locked but now it's offical unlocked before i updated to ISO6

    why my iphone can not be activated when I updated to IS06?
    My iphone is 3gs 8g, and original locked but now it's offical unlocked before i updated to ISO6.
    iphone information:
    iphone 3gs
    Model:MC640LL
    SN:84xxxxEDG
    <Edited By Host>

    That means your phone is now a brick. Congratulations.
    That's a risk you take when you decide to hack the phone.
    You can't get any help here. Discussing hacked and jailbroken devices is forbidden by the terms of service.
    Maybe you can find something on google that will help you.

  • Why my spotlight can not find my personal files ? It can find them before but can not find them now,I want to know why?

    why my spotlight can not find my personal files ? It can find them before but can not find them now,I want to know why?

    From the menu bar, select
     ▹ System Preferences ▹ Spotlight ▹ Privacy
    The list of items excluded from Spotlight indexing is shown (it may be empty.) Click the plus (“+”) icon to add an item to the list. Select your boot volume (under DEVICES) and add it to the list. Then remove it from the list by selecting it and clicking the minus (“-“) icon.
    Spotlight will rebuild the index. If you try to do a Spotlight search now from the magnifying-glass icon in the top right corner of the display, a pulsing dot will appear in the icon. When the dot disappears, the indexing is complete.

  • Why my firmware can not be upgraded?

    Why my firmware can not be upgraded? Do any one encounter the same problem? How can i fix It!!

    Hi BigFatCatMan,
    sorry I missed your earlier response.
    Assuming that you have tried downloading a "fresh" copy of the appropriate firmware update from http://www.apple.com/support/downloads/ and it still doesn't work, you might want to consider the firmware restoration CD process discussed at http://docs.info.apple.com/article.html?artnum=303469 and available through http://www.apple.com/support/downloads/firmwarerestorationcd13.html or http://www.apple.com/support/downloads/firmwarerestorationcd14.html (depending on precisely which MBP you have).
    Messing with firmware is always a tad risky, though, so that visit to a Genius bar might be worth trying, given the repeated anomaly.
    Rod
    Message was edited by: Rod Hagen

  • Why do I can not hear the siri's voice on my iphone speaker anymore, why do I can not hear the siri's voice on my iphone speaker anymore

    why do I can not hear the siri's voice on my iphone speaker anymore, why do I can not hear the siri's voice on my iphone speaker anymore

    All apps - all paid and free apps include DRM protection that is tied to the iTunes that was used to download the apps. This means you have apps on your iPhone that were downloaded with your daughter's iTunes account. Apps cannot be transferred or merged with another iTunes account.
    Delete the apps from your iPhone that were downloaded with your daughter's iTunes account to prevent being prompted for the account's password when there are app updates for the apps downloaded with the account. An iTunes account cannot be deleted.

  • Why my ipad can not update the ios7.1.1

    why my ipad can not update the ios 7.1.1

    Hello there, crivera350.
    The following Knowledge Base article offers up some great steps for if you are unable to update your iOS device:
    If you can't update or restore your iOS device
    http://support.apple.com/kb/ht1808
    Recovery mode erases your device and restores it, which should resolve the issue. If you previously synced with iTunes or iCloud, you may be able to restore from your backup after recovery.
    Turn off your device. If you can't turn it off, press and hold the Sleep/Wake and Home buttons at the same time and wait a few seconds for it to turn off.
    Plug the device's USB cable into your computer only.
    Hold down the device's Home button as you connect the USB cable to it.
    When you see the Connect to iTunes screen, release the Home button. If you don't see this screen, try steps 1 through 3 one more time.
    iTunes should open and display a message such as: "iTunes has detected an iPhone in recovery mode. You must restore this iPhone before it can be used with iTunes."
    Use iTunes to restore your device.
    If you don't see your device in iTunes, follow these steps for Mac or these for Windows.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • JMF threads can not stop?

    My program is designed for two-way audio conference, but now I met a problem that there are some threads can not stop before I start some calls(maybe 100 times).How can I release this threads? please help me, thank you in advanced.
    RTPEventHandler
    JMF thread: com.sun.media.ProcessEngine@6b9fee[ com.sun.media.ProcessEngine@6b9fee ] ( configureThread)
    JMF thread: SendEventQueue: com.sun.media.processor.unknown.Handler
    JMF thread: SendEventQueue: com.sun.media.ProcessEngine
    JMF thread: com.sun.media.processor.unknown.Handler@1ca8dc7[ com.sun.media.processor.unknown.Handler@1ca8dc7 ] ( configureThread)
    JMF thread: com.sun.media.ProcessEngine@e1d29e[ com.sun.media.ProcessEngine@e1d29e ] ( configureThread)

    Hi TGreybeard,
    Have you looked at the [[Firefox keeps opening many tabs or windows]] Knowledge Base article? There is some good information in there that should help you resolve the issue.
    Hopefully this helps!

  • I do not know why, but I can not go to the App Store! before I went there without any problems but now I can not connect with App Store

    I do not know why, but I can not go to the App Store! before I went there without any problems but now I can not connect with App Store

    Open the Finder. From the Finder menu bar click Finder > Go > Go to Folder
    Type or copy/paste:   ~/Library/Cookies
    Click Go then move the com.apple.appstore.plist file from the Cookies folder to the Trash.
    Try the App Store.

  • Why att store can not help for unlocking the phone

    I followed the instructions to unlock our two old iphones after having iPhone 6. I received "unlock" message for one phone and did not receive the message for other phone. I am not sure if the phone has been unlocked. I went to AT&T store at Bridgewater Commons, NJ. and like to know if it Is unlocked. I was told that they can not tell and I need go to T mobile store to find out. I stopped by T mobile and found out the phone is still locked. So I went back to the AT&T store to try getting help. Because I already tried to unlock this phone three times before. There were 10 ATT people in the store and only two or three customers there. I asked one of employees to tell me what I need to do. I was told that they do not have the service to help unlocking and I need to call customer service. I said to her that you have 10 employees here and why can not help, I would like to speak to the store manager. The store manager Dawn was there and she told me the same thing. They can not help and I need to call the customer service. I kept asking but why you can not help. Finally she said that she can help me to call the customer. She called and the phone was not go through. Finally the employee asked me the phone number and I thought that maybe she will help me to unlock. Actually she just made another unlock request online for me and I need to wait the email in 24 hours and redo the unlock process later. I would to know why att store can not help the customers to unlock their old phones after getting the new phones. Why att keeps 10 employees in one store and can not help to solve customer problems.

    Xiyufu wrote:
    ... I would to know why att store can not help the customers to unlock their old phones after getting the new phones. Why att keeps 10 employees in one store and can not help to solve customer problems.
    AT&T keeps 10 employees at a store in case they need them to assist customers with purchasing items, or with items recently purchased.
    The Store representatives can't help you with the unlock portion because it requires access to systems they are not authorized to access. If store employees could access the unlock system (other than the very same portal you can access) then there would be a high risk that there would be inapropriate unlocks by employees for their friends & relatives.  AT&T's solution is to not allow them access to those systems, and have everyone go through the same process so that everyone gets the same treatment.  If you are having problems with your unlock requests through the portal, try contacting customer support or you can send a private message to the escalation team at ATT Customer Care and someone will get in touch with you in two to three business days to help you get a resolution to your problems.
    To check for their reply, click the little blue envelope. in the top bar near your username.

  • Why db mirror can not set db recovery model to simple?

    Hi ,All
    I have a question . 
    DB replication can set db recovery model to simple ,why db mirror can not  db recovery model to simple.
    DB mirror must be set to full recovery model.
    As far as I know, whatever db mirror  and db replication ,there is a log reader to read the log in the ldf file
    DB mirror and DB replication are almost the same principle to replicate the db to another db server
    Thanks a lots
    Love SQL

    Database mirroring involves redoing every
    insert, update, and delete operation that occurs on the principal database onto the mirror database as quickly as possible. Redoing is accomplished by sending a stream of active transaction log records to the mirror server, which applies log records to the
    mirror database, in sequence, as quickly as possible. Unlike replication, which works at the logical level, database mirroring works at the level of the physical log record.
    There is no log reader agent in case of mirroring its more internal. Mirroring
    uses the transaction log to redo everything at the mirror site.  In simple recovery model, the transaction log is effectively transitory and only enough information is kept in the log for undo/redo to keep the database consistent during
    crash recovery. Thats why mirroring does not work in simple recovery model.

  • [SOLVED] Can not shutdown/restart from KDE with systemd

    Hello,
      Recently, following I switched to a pure systemd setup.  The process was simple and most things worked "right out of the bpx".  However, I can not shutdown or restart from KDE!
    Let's say that I do the 3 finger salute (ALT-CTRL-DEL) and select "Turn off computer" what I get is KDE shutting down, but then I will only get a console (TTY) login prompt.  Pressing ALT-CTRL-DEL then will trigger a reboot.  I can also login and use "systemctl poweroff".  However, I don't understand why it doesn't work straight from KDE.
    Are there some packages I must install?  Are there some systemd services that I must enable?  What other relevant info should I include in this post?
    Active units :
    UNIT LOAD ACTIVE SUB JOB DESCRIPTION
    proc-sys...misc.automount loaded active waiting Arbitrary Executable File Formats File System Automount Point
    sys-devi...d-card0.device loaded active plugged MCP79 High Definition Audio
    sys-devi...da-sda1.device loaded active plugged ST9500420ASG
    sys-devi...da-sda2.device loaded active plugged ST9500420ASG
    sys-devi...da-sda3.device loaded active plugged ST9500420ASG
    sys-devi...da-sda4.device loaded active plugged ST9500420ASG
    sys-devi...da-sda5.device loaded active plugged ST9500420ASG
    sys-devi...da-sda6.device loaded active plugged ST9500420ASG
    sys-devi...ock-sda.device loaded active plugged ST9500420ASG
    sys-devi...et-eth0.device loaded active plugged RTL8111/8168B PCI Express Gigabit Ethernet controller
    sys-devi...t-wlan0.device loaded active plugged AR928X Wireless Network Adapter (PCI-Express)
    sys-devi...y-ttyS0.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS0
    sys-devi...y-ttyS1.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS1
    sys-devi...y-ttyS2.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS2
    sys-devi...y-ttyS3.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS3
    sys-module-fuse.device loaded active plugged /sys/module/fuse
    -.mount loaded active mounted /
    dev-hugepages.mount loaded active mounted Huge Pages File System
    dev-mqueue.mount loaded active mounted POSIX Message Queue File System
    home.mount loaded active mounted /home
    run-user-1000-gvfs.mount loaded active mounted /run/user/1000/gvfs
    sys-fs-f...nections.mount loaded active mounted FUSE Control File System
    sys-kernel-debug.mount loaded active mounted Debug File System
    tmp.mount loaded active mounted /tmp
    cups.path loaded active waiting CUPS Printer Service Spool
    systemd-...d-console.path loaded active waiting Dispatch Password Requests to Console Directory Watch
    systemd-...word-wall.path loaded active waiting Forward Password Requests to Wall Directory Watch
    bluetooth.service loaded active running Bluetooth service
    colord-sane.service loaded active running Daemon for monitoring attached scanners and registering them with colord
    colord.service loaded active running Manage, Install and Generate Color Profiles
    console-...daemon.service loaded active running Console Manager
    console-...-start.service loaded active exited Console System Startup Logging
    cups.service loaded active running CUPS Printing Service
    dbus.service loaded active running D-Bus System Message Bus
    [email protected] loaded active running Getty on tty1
    kdm.service loaded active running K Display Manager
    NetworkManager.service loaded active running Network Manager
    sshd.service loaded active running OpenSSH Daemon
    systemd-journald.service loaded active running Journal Service
    systemd-logind.service loaded active running Login Service
    systemd-...s-load.service loaded active exited Load Kernel Modules
    systemd-...unt-fs.service loaded active exited Remount Root and Kernel File Systems
    systemd-sysctl.service loaded active exited Apply Kernel Variables
    systemd-...-setup.service loaded active exited Recreate Volatile Files and Directories
    systemd-...rigger.service loaded active exited udev Coldplug all Devices
    systemd-udevd.service loaded active running udev Kernel Device Manager
    systemd-...ssions.service loaded active exited Permit User Sessions
    systemd-...-setup.service loaded active exited Setup Virtual Console
    udisks2.service loaded active running Storage Daemon
    upower.service loaded active running Daemon for power management
    wpa_supplicant.service loaded active running WPA supplicant
    cups.socket loaded active running CUPS Printing Service Sockets
    dbus.socket loaded active running D-Bus System Message Bus Socket
    systemd-initctl.socket loaded active listening /dev/initctl Compatibility Named Pipe
    systemd-journald.socket loaded active running Journal Socket
    systemd-shutdownd.socket loaded active listening Delayed Shutdown Socket
    systemd-...control.socket loaded active listening udev Control Socket
    systemd-...-kernel.socket loaded active running udev Kernel Socket
    basic.target loaded active active Basic System
    cryptsetup.target loaded active active Encrypted Volumes
    getty.target loaded active active Login Prompts
    graphical.target loaded active active Graphical Interface
    local-fs-pre.target loaded active active Local File Systems (Pre)
    local-fs.target loaded active active Local File Systems
    multi-user.target loaded active active Multi-User
    network.target loaded active active Network
    remote-fs.target loaded active active Remote File Systems
    sockets.target loaded active active Sockets
    sound.target loaded active active Sound Card
    swap.target loaded active active Swap
    sysinit.target loaded active active System Initialization
    systemd-...es-clean.timer loaded active waiting Daily Cleanup of Temporary Directories
    LOAD = Reflects whether the unit definition was properly loaded.
    ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
    SUB = The low-level unit activation state, values depend on unit type.
    JOB = Pending job for the unit.
    72 units listed. Pass --all to see inactive units, too.
    Last edited by Prozzaks (2012-08-20 17:35:48)

    Demon wrote:For me the system only halts, it does not poweroff. How I can solve this?
    As bgc1954 said, there is also a symlink "/sbin/poweroff". Just edit the file "/usr/share/config/kdm/kdmrc", go to [shutdown] an replace the line "HaltCmd=/sbin/halt" with "HaltCmd=/sbin/poweroff".

Maybe you are looking for

  • ITunes hang due to iTunes Match

    My iTune hang every turn on iTunes Match. If I turn it on, I can't download/update large application or update all. I have to update one by one and only small one that's success (<100 MB). iTunes Match also not working on my MBP. If I download nothin

  • Adding a stock ticker to an iWeb site?

    Does iWeb not support Yahoo! Badges? http://finance.yahoo.com/badges They use something called iFrame. Is that different than HTML? Anyone know how I can add a stock ticker to my iWeb page? http://web.mac.com/michaelgrothaus/

  • IChat in Leopard no longer include remote sharing or screen sharing?

    They've posted new Leopard features on the site and the iChat AV movie no longer mentions screen sharing or remote sharing (ie. remote desktop) and I don't believe it was mentioned in the keynote. Anyone have any insights on whether this feature is s

  • Album work display on ipod

    I just got the new 30gb ipod with video and i want the album cover work to show up on the ipod with the song. i went to itunes went to preferences and selected that the ipod be updated automatically with the album cover work. then i update it but non

  • Imported iphoto's have disappeared

    maybe a month and half ago i imported my girlfriends photos onto my mac (she has her own user name etc) we have obiously deleted all the photos off from her phone and went into iphoto yesterday to get some photos and there is no photos I have used th