Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3235048
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:27:43+00:00 2026-05-17T17:27:43+00:00

some Function() { for(xxxxxx){ //a infinite loop or just a long code loading an

  • 0
some Function()
{  
    for(xxxxxx){
         //a infinite loop or just a long code loading an running stuff from a list
    }
}

ActionListener Panic(yyyyyyyy)
{
     Stops the infinite loop by list.clear() or insert some thing into the list and break the loop
}

I is trying to make a panic button to stop my code, problem is when Java is running some thing all the actionListener gets queued up and fires after my big for loop finish its stuff. This is probably a silly question but i can’t seem to fig out. Only solution i can think of is making this a thread( kinda hard and not sure if it will work ) or give a pop up message ask if user want to continue every cycle( too much prompt ). Just want to have a Red button that either break the loop and destroy the program much like Ctrl Z in linux and red stop button in eclipse or the Cancel button that stops your file transfer.

Thanks for looking =D
Lots and Lots of thanks

Oh btw, if the solution is Thread, please put it in the example i have above. I has almost no idea how to write a thread =(

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:27:43+00:00Added an answer on May 17, 2026 at 5:27 pm

    If you want to stop an infinite (or very long) loop, the loop must regularly ensure if it has not been interrupted.

    public class AlmostInfinite extends Thread {
        public void run() {
            while (!Thread.interrupted()) {
                /* Do some work, not too long */
            }
            cleanUp();
        }
    
        private cleanUp() {
            /* close network connections, files and other resources */
        }
    }
    
    ActionListener panic(AlmostInfinite t)
    {
        t.interrupt();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that uses the Oracle function add_months to increment a Date
I'm in the process of porting some code from Linux to Mac OS X.
I have some function to find a value: struct FindPredicate { FindPredicate(const SomeType& t)
When I have some function of type like f :: (Ord a) => a
I am writing a program that is meant to be extended by some function
I've got a function creating some XmlDocument: public string CreateOutputXmlString(ICollection<Field> fields) { XmlWriterSettings settings
I am having some difficulty writing a function that will search through a directory
here is some sample javascript: SomeObjectType = function() { } SomeObjectType.prototype = { field1:
I have some questions about Perl's map function. Specifically: How does %hash = map
I am attempting to pull some information from my tnsnames file using regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.