Make me stop

I can't make this thread stop. When the counter value is 20, I want to stop this thread. How do I do it?
public class StopThread extends Thread{
     public static void main(String []args){
               new StopThread().desing();
     public void desing() {
          Thread t=new Thread(new Threadclass("A"));
          t.start();
    class Threadclass extends Thread{
         String msg;
         public Threadclass(String msg){
              this.msg=msg;
         public void run() {
               try{
                    int counter=0;
                    while(true){
                         if(counter==30){
                              System.out.println("I'm sleeping");
                              Thread.sleep(10000);
                         if(counter==20){
                              System.out.println("making it stop----------");
                              Thread currentThread=Thread.currentThread();
                              Thread t=currentThread;
                              currentThread=null;
                              t.interrupt();
                         System.out.println("class counter "+ msg + "count value "+counter++);
               }catch(Exception e){
                    e.printStackTrace();
}

Thanks baftos idea really worked. I have also tried what jverd mentioned and was able to stop the thread. Please check whether this is a good way to stop it?
Another question: When/Why should we make a method static?
public class StopThread {
     public static void main(String []args){
          new StopThread().desing();
     public void desing() {
          Thread t=new Thread(new Threadclass("A"));
          t.start();
    class Threadclass implements Runnable{
         String msg;
         public Threadclass(String msg){
              this.msg=msg;
         public void run() {
       try{
          int counter=0;
          while(true){
               if(counter==30){
                    System.out.println("I'm sleeping");
                    Thread.sleep(10000);
               if(counter==20){
                    System.out.println("making it stop----------");
                     Thread currentThread=Thread.currentThread();
                       currentThread.interrupt();
                   if(currentThread.interrupted()){
                        return;
          System.out.println("class counter "+ msg + "count value "+counter++);
     }catch(Exception e){
          e.printStackTrace();
}

Similar Messages

  • Since update to iOS 7, every time I open an app a pop up message telling me to connect to iTunes to use push notifications comes up. EVERY TIME! How do I make it stop???

    Since update to iOS 7, every time I open an app a pop up message telling me to connect to iTunes to use push notifications comes up. EVERY TIME! How do I make it stop???

    Do you use iTunes with your iPad and if so, have you tried syncing your iPad with iTunes since you updated the iOS?

  • Something keeps trying to download on my mac and I don't know what it is. It is not in the apple store and just comes out nowhere and request for my password to download something and I don't know what it is. How to make this stop?

    Something keeps trying to download on my mac and I don't know what it is. It is not in the apple store and just comes out nowhere and request for my password to download something and I don't know what it is. How to make this stop? It pops up every single day.

    Erica,
         I can, with 99.99% certainty, tell you that you are absolutely right in not wanting to download or install this "Helper," whatever it is (but we can be equally certain it would not "help" anything).
         I cannot comment as to Oglethorpe's recommendation of 'adwaremedic'; I am unfamiliar with it.  His links to the Apple discussion and support pages warrant your time and attention.
         It might be really simple -- Trying looking in your Downloads folder, trash anything that you don't know with certainty is something you want to keep, and then Secure Empty your Trash. Then remove the AdBlock extension, LastPass, and Web of Trust extensions to Safari and re-boot. If the issue goes away, still be extraordinarily careful in the future.
         Unfortunately, it's probably not going to be that simple to get rid of, in which case I'd then try the line by line editing in HT203987. 
         I have no further suggestions (other than a complete wipe and re-install...but that's a pain because trying to restore from Time Machine would simply ... restore the Mal).
       For the rest of us, please post when you find a solution.
         Best.
         BPW
      (Also, try to edit your second post -- black out your last name on the screenshot and re-post it for others)

  • I downloaded a program to be able to open docx diles and now every time I try to open one there are endless new tabs that read "new Tab" scrollomig across the top of the screen. How do I make it stop?

    I had an old version of office so I tried to install a free download that will allow me to open docx files. Now when I try to open one and endless stream of tabs that say "New Tab" scrolls across the top of the page. How do I make it stop. I already went and got office 2010 but it is still doing it. It does not do it if I use Internet Exployer for the browser.

    See [[Firefox keeps opening many tabs or windows]]

  • My nephew and I use the same iTunes account and when I add an app it is loaded on to his iPhone and vice versa... How do I make that stop?

    My nephew and I use the same iTunes account and when I add an app it is loaded on to his iPhone and vice versa... How do I make that stop? I have already unchecked the "Auto Update Apps" button. It happens with all purchases in the app store and on iTunes. HELP!

    I also think separate accounts is the way to go....if he is over 13yrs also remember if you do make an account for him and use your bank card all purchases will be charged to your card.

  • Text messages showing as number@vtext, can't make it stop

    I posted this in the Android section but realized that may not be the right place.
    Day 1
    My phone was messed up earlier today so I was sending text messages to my daughter from the verizon website.  Now that I have my phone sorted out text messages from her show up as [email protected] We are sending text messages hand set to hand set, not using the web anymore. It is so annoying, not only that but it actually duplicates the messages. The body shows up with (message) message. My replies to her show as both my regular contact and vtext.com, alternating not at the same time.  I want it back to normal. Does anyone have any ideas?
    Day 2
    Ugh, if anyone has any ideas I would appreciate it. This is so irritating. I went through my phone and my daughters, deleted all of our messages to each other, deleted each other as contacts. Cleared the cache in our phones. Re-added each of us as contacts and it is still doing it! So instead of messages from her showing up with her name they show with [email protected] and it duplicates the body of the message. If she says 'do you want to go to lunch' it shows up as (do you want to go to lunch) do you want to go to lunch. It is so annoying. This continues to happen even after we start new messages to each other, being sure that we select our mobile numbers. We are not entering the vtext anywhere. Someone help me make it stop!  This is not happening with any other contacts, only her.
    Thanks for any help.

    Laura,
    Make sure you have deleted all contact information from BOTH phones, and all messages from each other on BOTH PHONES.  Then restart the phones.  It's important that there are no remaining messages or contact information when you try to start anew.
    THEN, send a text to each other using only the manually entered phone number.  If that is successful (it comes from the phone number), then add the phone number and contact information from the message.
    It seems it's still seeing the vtext messaging somehow, so it's critical that information is GONE and you are starting totally new with the phone number only.
    HTH,

  • Every day, my keyboard and track pad don't work, so I have to shut my computer off and start it back up. It does this multiple times a day. What can I do to make it stop doing this?

    Every day, my keyboard and track pad don't work, so I have to shut my computer off and start it back up. It does this multiple times a day. What can I do to make it stop doing this?

    Try resetting your SMC and PRAM.
    Resetting the System Management Controller  >>
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD + OCZ Vertex 3 SSD Boot HD 
    Got problems with your Apple iDevice-like iPhone, iPad or iPod touch? Try Troubleshooting 101

  • How do i make Keychain stop asking for my PW when I launch Entourage?

    I have really never had to do anything with Keychain, ever since I started using OSX back in the 10.2.x days.
    I just used my computer. No problem; it's a Mac!   I kind of had a vague idea what Keychain was, but i really never interacted with it.
    Same was true when I upgraded my non-Intel Powerbook from 10.3.9 to 10.5.8.  Things went fine, for over a year.
    But I recently had occasion to wipe my HD and reinstall 10.5.8.
    Now, keychain asks for my login admin password every time I launch Entourage.
    And no matter how many times i type it in, it never remembers.
    That's a pain, and I have no clue how to make it stop doing that.
    When I open the Keychain access utility and click on Help to try and learn what Keychain is all about, nothing happens.  That's no help!
    When I run Keychain Repair, it says everything is verified, and repair says there's nothing to repair.
    Within the keychain access utility, i see a list of references to many of the passwords that I entered over the past several years and the sites I used them on.
    Are all those passwords with their matching URLs stored somewhere on my Mac?  I have always religiously NOT done this, for obvious reasons. 
    Makes me kind of uneasy, 'encrypted' or not.  I'm always skeptical of the "trust me..." approach to computer security.
    (If hackers can hack into the Defense Dept., the average Mac would seem to be a piece of cake.)
    ...Altho I suppose that could be a good argument for having DoD switch over to Macs....:-)
    Anyway, keychain for me is a mystery wrapped in an enigma, and it has now become a bit of an annoyance and an inconvenience.
    Whenever I need annoyances and inconveniences, I can always get those at work...on my Windows PC.
    So how do I get Keychain to stop asking me for my Admin username/password every time I launch Entourage?

    Hello,
    >Are all those passwords with their matching URLs stored somewhere on my Mac?
    Yes, that IS the Keychain.
    Mac OS X 10.4: Keychain Access asks for keychain "login" after changing login password...
    http://support.apple.com/kb/HT1631
    Resetting your keychain in Mac OS X...
    If Keychain First Aid finds an issue that it cannot repair, or if you do not know your keychain password, you may need to reset your keychain.
    http://support.apple.com/kb/TS1544
    And finally...
    Keychain is no longer able to update itself when I upgrade an application...
    http://unsanity.org/archives/2007_01.php
    >Makes me kind of uneasy, 'encrypted' or not.  I'm always skeptical of the "trust me..." approach to computer security.
    But if it didn't you be bothered to put in hundrefds of usernames & Passwords a day most likely.

  • On images that are long and narrow horizontally, iPhoto truncates them and automaticall crops off part of each end of the image.  How can I make it stop?

    On images that are long and narrow horizontally, iPhoto truncates them and automatically crops off part of each end of the image.  the thumbnail has a jagged, serrated edge at both ends.  How can I make it stop?

    Then I do not get your problem - you can import the photo - you can find the photo and you can edit and save the photo - what more do you want?
    By defination thumbnails are small images to help you find the large image - the large image is fine and you can find it fine - and you know it is only showing part of the image because of the "jagged ends"
    If you think think that iPhoto should display long thumbnails suggest to Apple - iPhoto menu ==> provide iPhoto Feedback
    as to your digital photoframe - contact them - in general gital photos frames display one and only one aspect ratio and any photo that is not in that aspect ratio will be modified to display - either cropped to the proper size for the frame or have 'White" space added to fill the frame - that function is totally controled by the Digital Photo frame and any otptions you have will be in the manual or on the support web site for the frame - to put it in old film terms - you can not put an 8x10 print in a 5x7 frame unless you cut the photo down (or a 8x15 photo in an 8x10 frame either)
    LN

  • When filling out a form, some fields copy to others when I tab to the next. How can I make this stop?

    When filling out a form, some fields copy to others when I tab to the next. How can I make this stop?

    You can't using Adobe Reader. It looks like whomever created the form used the same identifiers (names) for various fields. Each field with the same name will populate with the information used in another field of the same name. This is intentional.
    Normally when I see this, it tells me that someone created an initial field then copy/pasted it to make additional fields but forgot to change the names.

  • Just restored my iPhone from iCloud. My wife and I have always shared one iCloud ID. But since my restore, when a call comes in, it rings on both my phone and hers. How can I make this stop?

    Just restored my iPhone 5  from iCloud. My wife and I have always shared one iCloud ID. But since my restore, when a call comes in, it rings on both my phone and hers. How can I make this stop?  We had it all set up fine before the restore, and there was a trick to it in the settings.  I've noticed that since my restore, her phone has picked up what looks like the symbol of a phone in the upper right corner of the display, right next to the Bluetooth symbol.

    Hi Big Slick,
    Welcome to the Apple Support Community!
    It sounds like your iPhones may be using a new feature in iOS 8 called Continuity. The following article and information explains how to set up this feature for phone calls. You can review the information on the setup to reverse this effect. My suggestion would be to turn off FaceTime on one of the devices.
    Connect your iPhone, iPad, iPod touch, and Mac using Continuity
    Phone calls
    With Continuity, you can make and receive cellular phone calls from your iPad, iPod touch, or Mac when your iPhone is on the same Wi-Fi network.
    To make and receive phone calls, here's what you need:
    Sign in to the same iCloud account on all your devices, including your Mac.
    Your iPhone and your iPad or iPod touch need to use iOS 8 or later. Your Mac needs to use OS X Yosemite.
    All devices must be on the same Wi-Fi network.
    All devices must be signed in to FaceTime using the same iCloud account. This means any device that shares your Apple ID will get your phone calls. Look below for instructions on how to turn off iPhone cellular calls.
    Wi-Fi Calling needs to be off. Go to Settings > Phone. If you see Wi-Fi Calling, turn it off.
    Cheers,
    Joe

  • TB Automatically Opens Bing Settings and Add-On Settings at Startup. How to make it stop?

    Heyo,
    So I'm punting as tech support in my office, and don't use TB myself. What's happening is on startup, a Bing settings page and the TB add-ons page are loading in tabs in addition to the inbox tab.
    X'ing the tabs individually does remove them, but I need to make them stop loading at startup for the sanity of this older gentleman.
    There are no modifiers on the shortcuts to open the program, no homepages listed in options. What am I missing?
    Thanks buckets for any input.

    The only time that this gets messed up is when they run cleaner software like CCleaner that deletes settings because it thinks it knows best. You can set CCleaner to leave the Thunderbird, or other software, files along to stop that issue.
    Glad you got it working.
    The other common issue is people complaining about all the message tabs accumulating across the top of the screen and moving the Inbox tab out of view. This is because they open messages in tabs and never close them. You can right click one tabs and select Close Other Tabs and then use the x to close the last one. Then explain to them how to close tabs after reading messages. :)

  • HT5557 My IPad keeps kicking me out on Ibooks, why? How do I make it stop?

    My IPad keeps kicking me out of IBooks, why.? How can I make it stop?

    Basics from the manual are restart, reset, restore.

  • When I'm bouncing a project, it freezes or doesnt stop bouncing and keeps going past its cut off. how do i make it stop and get back to normal?

    When I'm bouncing a project, it freezes or doesnt stop bouncing and keeps going past its cut off. how do i make it stop and get back to normal?

    Hi
    chorleyman wrote:
    you do have to actually define the area to be bounced in the dialogue window that comes up - there are some discrepencies in the way that the program behaves like that,
    Apart from the "Include Audio Tail" function, which can leave Logic bouncing for a very, very long time, there are generally, no discrepancies regarding the Bounce Locators:
    If Cycle is enabled, the bounce locators will be set to the cycle locators.
    If Cycle is off, and regions are selected, the bounce locators will be set to the selection.
    If cycle is off, and no regions are selected, the bounce locators will be set from the Project Start to the project end.
    It is smart to actually check that the bounce locators are set where you would like them to be.
    wildfire31 wrote:
    When I'm bouncing a project, it freezes or doesnt stop bouncing and keeps going past its cut off. how do i make it stop
    If you get caught with a bounce that does not stop, Command . (period) should do the trick.
    CCT

  • How can I make a stop motion animation using Premiere Elements 13?

    I am trying to make a stop motion animation with a series of still shots. So far I have managed to speed up the shots so that I have one frame per second but this is still not fast enough and I can't work out how to make them go any faster!
    I am working on a class project with my 8/9 year olds and the project has stalled at this point because I can't get past this hurdle. Any help would be greatly appreciated!

    yogawithlexi,
    Welcome to the forum.
    Im also needing to just edit the photos but adding text. Nothing fancy. I just want to make some flyers.
    For editing photos, to be output to the printed page (whether by a commercial printing service, or a desktop printer), I strongly recommend Photoshop Elements (PsE).
    If you need to output to a video file, then Premiere Elements (PrE) can possibly do what you want, but not for the printed page - at least not easily, and with the ultimate results. First, Video is not dependent on DPI/LPI (Dots Per Inch, or Lines Per Inch), where printed material will be. Also, while PrE can output a Still Image, the quality, when printed, will be far less, than what one can obtain with PsE.
    Do you currently have Photoshop Elements on your computer, or only Premiere Elements?
    Good luck,
    Hunt

  • Mozilla firefox start page keeps logging itself on after I close all internet windows I come back and there it is. Why??? Make it stop.

    mozilla firefox start page keeps logging itself on after I close all internet windows I come back and there it is. Why??? Make it stop.

    I've got the exact same issue! I'm pretty sure it just started today too. It's so bizarre because we've all been using Firefox 26.0 for at least a month, right? How could the ''about:home'' page all of a sudden cause this issue?
    I've been able to replicate this issue on a virtual machine running Windows XP SP3, so clearly it has nothing to do with Windows 7.

Maybe you are looking for

  • Using a 110v G4 DP 867 in the UK 220v

    I cant get a clear answer from anyone regarding using my DP 867(USA) that i want to take to the UK. Does it have an auto voltage sensor? Do I need to buy a transformer? Any help would be appreciated.

  • Implementing SQL Plan Management on Oracle Database 11.2.0.2

    Environment: Oracle Linux 5 update 10 (UEK) Oracle GI 11.2.0.2.0 (Oracle ASM 11.2.0.2) Oracle Database 11.2.0.2.0 Enterprise Edition with RAC option (3 nodes) No PSU applied/CPU July 2013 applied to RDBMS Database servicing Siebel CRM 8.1.1.1 Applica

  • Sql*Loader and Conc. Mgr.

    I would like for our users to submit a request (in GL) that will run sql*loader to load a file of their choosing to an oracle table. Oracle tells me I must use their consulting arm for this kind of question. Does anyone have any ideas on how to do th

  • What types of backend systems are involved (mainframe, SAP, etc.) for xi ?

    What types of backend systems are involved (mainframe, SAP, etc.) for xi project?

  • Modify Values Document Category List

    Hi All, Can you please explain how to modify values or add new ones to the Document Category list, that belongs to the manage contract documents Actions? I am working on OM > Blanket Sales Agreement > Thanks for your help Deneb