Advertisement
kolyapustovoit

Untitled

Mar 31st, 2023
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | Source Code | 0 0
  1. import java.io.Closeable;
  2.  
  3. public class SomeClass extends Thread implements Closeable, AutoCloseable {
  4.     private Boolean isActive = true;
  5.  
  6.     public void run() {
  7.         System.out.println("START");
  8.         while (isActive) {
  9.             try {
  10.                 Thread.sleep(1000);
  11.                 System.out.println("ПКМ");
  12.             } catch (InterruptedException e) {
  13.                 throw new RuntimeException(e);
  14.             }
  15.         }
  16.         System.out.println("STOP");
  17.         System.out.println();
  18.     }
  19.  
  20.     @Override
  21.     public void close() {
  22.         isActive = false;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement