TestRunnable.java 447 B

12345678910111213141516171819
  1. public class TestRunnable {
  2. public static void main(String[] args) {
  3. MyRunnable runnable = new MyRunnable();
  4. Thread thread = new Thread(runnable);
  5. thread.start();
  6. }
  7. }
  8. class MyRunnable implements Runnable {
  9. @Override
  10. public void run() {
  11. try {
  12. Thread.sleep(1000);
  13. } catch (Exception e) {
  14. e.printStackTrace();
  15. }
  16. System.out.println("Finished.");
  17. }
  18. }