Does a thread can be declare once?

for example:
Thread thread = new Thread();
thread.start();
somewhere in my list code:
thread.stop_run();
thread.Interrupt();
i want to start thread again without:
Thread thread = new Thread();
thread.start();
just thread.start() and it will begin from the begining of a thread.
Is it can or not ???
thx....

You can not do that.
Once a thread is stopped, where yourThread.getState()==State.TERMINATED that thread can never be started again.
You can either just create a new instance of the thread like yourThread=new Thread(some class);
or you can avoid killing your thread in the first place. Once you're finished doing what you needed with that thread, put it to sleep for a long time like Long.MAX_VALUE. That thread will sleep until you interrupt it again.
To make sure the thread will execute from the beginning put the thread code in a infinite loop and use the continue command statement to reset the execution when you need to restart the thread.
In your code then every time you press a button or whatever starts the thread, first check the state of the thread if it's WAITING then just interrupt it, if it's NEW then just do what you regularly do.
It's probably easier to just create a new instance, but if you want to avoid that then try the above technique.

Similar Messages

  • HT4060 I just received the 3rd generation and my wall charger does not charge. If I use my Sony docking station it does.  I can't carry my docking station! Please help!!

    I just received the 3rd generation and my wall charger does not charge. If I use my Sony docking station it does.  I can't carry my docking station! Please help!!

    Did you get a charger with the iPad 3?
    Could be the charger or cable. Plug the USB cable into your computer. It may say "Not Charging", however, it is charging slowly and will verify that the cable is good.
    Try this first - Reset 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 - let go of the buttons. (This is equivalent to rebooting your computer.)
    The quickest way (and really the only way) to charge your iPad is with the included 10W or 12W (5W on Mini) USB Power Adapter. iPad will also charge, although more slowly, when attached to a computer with a high-power USB port (many recent Mac computers) or with an iPhone Power Adapter (5W). When attached to a computer via a standard USB port (2.5W, most PCs or older Mac computers) iPad will charge very slowly (but iPad indicates not charging). Make sure your computer is on while charging iPad via USB. If iPad is connected to a computer that’s turned off or is in sleep or standby mode, the iPad battery will continue to drain.
    Apple recommends that once a month you let the iPad fully discharge & then recharge to 100%.
    How to Calibrate Your Mac, iPhone, or iPad Battery
    http://www.macblend.com/how-to-calibrate-your-mac-iphone-or-ipad-battery/
    At this link http://www.tomshardware.com/reviews/galaxy-tab-android-tablet,3014-11.html , tests show that the iPad 2 battery (25 watt-hours) will charge to 90% in 3 hours 1 minute. It will charge to 100% in 4 hours 2 minutes. The new iPad has a larger capacity battery (42 watt-hours), so using the 10W charger will obviously take longer. If you are using your iPad while charging, it will take even longer. It's best to turn your new iPad OFF and charge over night. Also look at The iPad's charging challenge explained http://www.macworld.com/article/1150356/ipadcharging.html
    Also, if you have a 3rd generation iPad, look at
    Apple: iPad Battery Nothing to Get Charged Up About
    http://allthingsd.com/20120327/apple-ipad-battery-nothing-to-get-charged-up-abou t/
    Apple Explains New iPad's Continued Charging Beyond 100% Battery Level
    http://www.macrumors.com/2012/03/27/apple-explains-new-ipads-continued-charging- beyond-100-battery-level/
    New iPad Takes Much Longer to Charge Than iPad 2
    http://www.iphonehacks.com/2012/03/new-ipad-takes-much-longer-to-charge-than-ipa d-2.html
    Apple Batteries - iPad http://www.apple.com/batteries/ipad.html
    iPhone: Hardware troubleshooting (Power/Battery section also applies to iPad)
    http://support.apple.com/kb/TS2802
    Extend iPad Battery Life (Look at pjl123 comment)
    https://discussions.apple.com/thread/3921324?tstart=30
    iOS 7 Battery Life Draining Too Fast? It’s Easy to Fix
    http://osxdaily.com/2013/09/19/ios-7-battery-life-fix/
    New iPad Slow to Recharge, Barely Charges During Use
    http://www.pcworld.com/article/252326/new_ipad_slow_to_recharge_barely_charges_d uring_use.html
    iPad: Charging the battery
    http://support.apple.com/kb/HT4060
    Best Practices for iPad Battery Charging
    http://www.ilounge.com/index.php/articles/comments/best-practices-for-ipad-batte ry-charging/
    Tips About Charging for New iPad 3
    http://goodscool-electronics.blogspot.com/2012/04/tips-about-charging-for-new-ip ad-3.html
    How to Save and Prolong the battery life of your new ipad
    https://discussions.apple.com/thread/4480944?tstart=0
    Prolong battery lifespan for iPad / iPad 2 / iPad 3: charging tips
    http://thehowto.wikidot.com/prolong-battery-lifespan-for-ipad
    iPhone, iPod, Using the iPad Charger
    http://support.apple.com/kb/HT4327
    Install and use Battery Doctor HD
    http://itunes.apple.com/tw/app/battery-doctor-hd/id459702901?mt=8
    To Extend a Device’s Battery Life, Get to Know It Better
    http://tinyurl.com/b67c7xz
    iPad Battery Replacement
    http://www.apple.com/batteries/replacements.html
    In rare instances when using the Camera Connection Kit, you may notice that iPad does not charge after using the Camera Connection Kit. Disconnecting and reconnecting the iPad from the charger will resolve this issue.
     Cheers, Tom

  • How can i declare a single radio button field in selection-screen ?

    How can i declare a single radio button field in selection-screen ?

    >
    Rob Burbank wrote:
    > And how will you turn it off once it is turned on??
    >
    > Rob
    Thats correct ;)...See ravi if users will ask so many things its our Job to convay the correct solution ....
    Just post your org requirement..SOo some body guide you better//
    Sas

  • Task Manager Not loading Properly. Giving Error No more threads can be created in the System.NAPStatus UI and Some other Task related Errors

    I have a problem with the Task Scheduler. It is not opening properly it is giving Error Message box at this time i am unable to post. The Tasks Scheduler is starts with a error alert "No more threads can be created in the System.NAPStatus UI".
     I am unable to view the history of the tasks schecduled.It is giving message as 
    "The user account does not have permission to Access the Task History."
    How to fix it. It is frustrating as can't able to track my Tasks and Create new Tasks. Any Suggestions helpful.
    Thanks in Advance.
    RehaanKhan. M

    Hi,
    Thanks for your post.
    Please check event viewer if there are some error logs?
    Meanwhile, there is a similar thread has been discussed:
    Receiving error about "no more threads"
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/9a9e22e4-d947-4d19-b06c-aaadda624dbc/receiving-error-about-no-more-threads?forum=winservergen
    Regards.
    Vivian Wang

  • Calling thread.start() more than once concurrently

    Hi, I got a simple doubt that may feel awkward or absurd to people who are well versed in the java threading concepts. I just thought of it and as I couldn't get an easy answer I am posting this.
    Consider a class that implements the runnable interface. The run() method of the class is implemented with just a System.out.println(). If I make an instance of this class, say 't' in the main method and calling t.start() susequently twice or thrice; an illegal ThreadStateException will be thrown. The code snippet is as follows:
    ThreadTest t = new ThreadTest();
    t.start();
    t.start();
    It is understood that state of the thread object is changed to run state and so, if it is again started, it must be thrown. So if I put a Thread.sleep() inbetween these two subsequent calls assuming that the main method thread will be sleeping. So there is sufficient time for the first thread to terminate and then only the second will start - still the same exception is being thrown. I tried putting the synchronized qualifier for run too, still no effect - the same only happening. Why the java thread object is made in such a way that once the thread changes it state from Runnable to Running and then finally to dead state, it can be restated back to Runnable state, such that the start() method can be called again. Is it possible or not? Please post your comments.

    As ejp says you can't start a thread more than once - even if it has already terminated after the first start.
    By making threads a one-shot it simplifies reasoning about them: you don't have to wonder whether a second start() will work or not, depending on whether the thread has completed its first "incarnation". It also makes it easier to ensure thread resources are reclaimed. It also avoids semantic issues like whether anything about the thread is "carried over" across incarnations.
    This might seem a limitation but there are many ways around it - simply don't let the thread terminate. Whatever control structure you would enforce by re-starting the thread can be emulated without letting the thread terminate in between "executions".

  • What does mean You can include static and dynamic tables into a Smart Form?

    Hi guys,
    If you check the official documentation for Smart forms in the Internet you will read that the initial pharagraphs of the text tell you "Tables - You can include static and dynamic tables into a Smart Form. Dynamic tables enable you to display tables whose size is determined only at the moment of their output by the number of the table items to be displayed". The link is the following: http://help.sap.com/saphelp_nw04/helpdata/en/a5/de6838abce021ae10000009b38f842/frameset.htm
    I was wondering if this means that I can use field symbols with dynamical number of columns to print a smart form. Because it would be great since the customer wanted a dynamical report depending on the week day it was (If Monday, there was only 12 columns, but if Friday, it will be 52 columns (1 column more for every day elapsed in the current week)). I had to create 5 different forms, but I think using field symbols I had spent less effort. Do you know if it is really possible? If not, then what does mean "You can include static and dynamic tables into a Smart Form"?
    Thank you in advance

    Hi ,
    The concept of static and dynamic tables in smartforms, means you can use template- ( static table as no of rows and columns is fixed). Also you can use table- dynamic as the no of rows will depend on your line items.
    Hope this will help you to close this thread.
    Also, try to find this answer in posted forums. Creating a new forum everytime just increases the network traffic. So please try to avoid it.
    Regards,
    Vinit

  • Bex report does not show loaded data at once

    Hi experts,
    Why Bex report does not show loaded data at once after loading is finished but after some time?
    Could be the reason of it:
    a) huge amount of data in infocube.
    b) there are no deleting/creating indexes before/after loading, because it takes too much time
    c) anothe reason?
    Thank you,
    Tigr_Z

    Hi Tigr,
    A and B both can be the reasons behind, but normally in case of B option the results on report output can be wrong like duplicates sort of showing you double figures.
    C - it can be resource issue, so please look into all and double check with basis if thats the case.
    Regards
    Sunny

  • The same user can only login once

    Hello,
    I have a problem with my system. I made a system where you must login.
    I use the following code:
    boolean login = false;
    String username= request.getParameter("username");
    String password= request.getParameter("password");
    User user= Usermutations.makeviaUsername(username);
    if (user.getPassword().equals(password) && !password.equals("")) login= true;
    if (login) ReqD = getServletContext().getRequestDispatcher("/Overview.jsp");
    else ReqD = getServletContext().getRequestDispatcher("/False.jsp");
    request.getSession().setAttribute("user",user);
    request.getSession().setAttribute("username",username);
    request.getSession().setAttribute("password",password);
    if (ReqD != null) ReqD.forward(request,response);
    //Clean up resources
    public void destroy()
    Now I want that the same user can only login once. So when a user login with his username and password, no one else can login with that user name and password.
    I don't wan't to put the username in the database and then validate if the user is already logged in, because then the user must logout and not close the webbrowser else the user stays in the system.
    Does anyone knows a solution top this problem.
    Thanks in advance,
    Henk

    So I wan't the database and when the user is logged in
    the name is set in the database. But when the user
    clicks on the X (close button in the browser his
    username must be deleted from the database)You can't tell when the user does that (or perhaps you can sometimes, with difficulty). But even if you could it doesn't solve your problem. Many people keep their browsers open all day, and -- you may find this shocking -- they go to sites other than yours.
    So basically, if you don't provide them with a logout button you can't tell when they "leave" your site. And even if you do provide them with a logout button, they won't necessarily bother to use it. So you're left with waiting until the session expires, and then logging them out. This also means that if they come back to your site while the session is still active, then they are still logged in. This is not an error and you should not treat it as one.
    PC²

  • Can the ipad reminders app import tasks from the calendar app so I can enter items once?

    Can the ipad reminders app import tasks from the calendar app so I can enter items once?

    Depends on an account. The Tasks in Exchange will populate Reminders, and you can use Reminders in iCloud, but natively entering something in Calendar does not reflect in Reminders.

  • How can I declare shared folder in SAP transaction AL11

    Hi,
    In Application Adapters Guide for ODI (downloaded from Oracle Homepage) have a paragraph:
    "the shared folder needs to be declared in SAP transaction AL11 and the folder opens successfully in AL11"
    if my folder for share is: C:\ABCFolder
    how can I declare the shared folder in SAP transaction AL11, and how to open it ?
    Thanks for reply.

    Hi,
    Once you delete the session in SM35, it is not possibel to restore it back.
    Check if you have also deleted the logs? Logs can exists after deleting the Session, provide you have not deleted the logs too.
    It is not possible to create one more session using AFAB.
    still if you want to do it, then in the selection screen at least change one of the parameter (Company code, Fiscal year, Posting period).
    IF you still do not want to change the above input parameters, then there is another option, i.e. create a new assest and then run the AFAB with the radio button in REPEAT RUN.
    Hope this is clear
    BR
    Sree

  • I am trying to set up a co-worker's email on her iPhone and I don't know what her password for Thunderbird is and neither does she. Can I get the password?

    I am trying to set up a co-worker's email on her iPhone and I don't know what her password for Thunderbird is and neither does she. Can I get the password somehow, or what do you recommend?

    There is no password to Thunderbird. The password you need is to the email account. Contact the email provider for password reset.

  • HT4199 My macbook pro and ipad does not recognize my printer on my wireless network, but my pc does. How can I get my apple products to see it on the network so I can print wirelessly?     My printer is a Brother MFC-J270W

    My macbook pro and ipad does not recognize my printer on my wireless network, but my pc does. How can I get my apple products to see it on the network so I can print wirelessly?     My printer is a Brother MFC-J270W

    try disabling email scanning for incoming mail.
    One of the last things that occurs is the mail server and Thunderbird sign off on "where we are up to" and Thunderbird stores this state information in the popstate.dat file in your profile (there is one in each POP mail account folder). If the anti virus, or you for that matter, end the conversation a few seconds early that hand off does not occur and the popstate is not stored.

  • How many threads can be running at the same time

    Hi!!
    Dows anyone knows how many Threads can be running at the same time in the JVM.
    I'm making a multi thread client-server app and I would like to know how much simultneous connections the JVM support. I'm using one Thread per connection.

    Hi, thanks to all for your answers.
    I think that I made the wrong question, as you said: "that means the number of threads currently created".
    I'm worry about this because my application is already online (It's a mail server -SMTP and POP3 server using ORACLE for the users database- ) and some other user post in the "multi-tread forum" that almost any JVM can only have 700 threads created at the same time, and I've never heard or read anything about this.
    what you mean with the stack space (memory??)
    I'm using the JavaWebServer 2.0 and a servlet to start the main Thread.
    Again Thanks to all for the answers but I think that the schapel answer is the one that solve my doubt...

  • Windows vista not recognizing my iphone4s when i open itunes, keep getting trust / dont trust message on phone and always press trust. Not sure why it's started doing it. Can not synch iphone at all or add new music....aaahhh

    windows vista not recognizing my iphone4s when i open itunes, keep getting trust / dont trust message on phone and always press trust. Not sure why it's started doing it. Can not synch iphone at all or add new music....as itunes does not pick up the phone I have connected anymore. My ipod synchs fine still and thats over 6 years old!

    Hi rubicon7,
    Welcome to the Support Communities!
    The article below may be able to help you with this.
    Click on the link to see more details and screenshots. 
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/TS1538
    If the issue is not resolved, you may need to uninstall iTunes and all of it's components, and reinstall the latest version as explained in this article:
    Issues installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/HT1926
    I hope this information helps ....
    Have a great day!
    - Judy

  • My iPod touch needs to be restored. however, all of my movies/apps/songs/photos are not backed up on my computer because the shop on my computer does not work. can i still get the memory on my iPod touch 32gb back?

    my iPod touch needs to be restored. however, all of my movies/apps/songs/photos are not backed up on my computer because the shop on my computer does not work. can i still get the memory on my iPod touch 32gb back?

    If you weren't able to sync the purchases to a computer previously and now your iPod needs to be restored so you can't sync it now, then you may be out of luck and will need to purchase your content again. Officially Apple does not allow redownloads of purchased items other than iPhone/iPod touch applications and iBooks. The official statement of their policy can be found here, among other places.
    You can try contacting iTunes Store Customer Service (select the "Music Purchases" or "Video Purchases" category, as appropriate, then "Lost or Missing Items". You'll find either an "Express Lane" button - just follow the instructions to get to the contact form - or an "Email Us" button) ") and explaining what happened. Reportedly in some cases Apple has allowed redownloading on a one-time basis. But don't count on it. 
    Good luck.

Maybe you are looking for