fork download
  1. class MyRunnable implements Runnable {
  2. @Override
  3. public void run() {
  4. for (int i = 0; i < 5; i++) {
  5. System.out.println(Thread.currentThread().getName() + ": Message " + (i + 1));
  6. }
  7. }
  8.  
  9. public static void main(String[] args) {
  10. Thread thread = new Thread(new MyRunnable());
  11. thread.start();
  12. }
  13. }
Success #stdin #stdout 0.13s 59636KB
stdin
Standard input is empty
stdout
Thread-0: Message 1
Thread-0: Message 2
Thread-0: Message 3
Thread-0: Message 4
Thread-0: Message 5