5

How can we break a loop which is on other class by just button press event in Java?

Comments
  • 4
    Set a bool value and check it in the loop.
  • 1
    Run it in a thread, and invoke its cancellation token.
  • 0
    @bkwilliam no actually the problem is, after running the project, the program goes directly to the while loop and on the layout there are two buttons (suppose A and B)
    Now if a button (A or B) is clicked, I want that click of button to break that loop and perform it's action and the while loop and button declarations are on different classes
  • 1
Add Comment