Created
October 2, 2016 22:51
-
-
Save igormukhin/8e0d601cd2e16b1ab511324d84db4bfc to your computer and use it in GitHub Desktop.
Template for demonstrating DCEVM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sample.dcevm; | |
import java.util.Date; | |
public class LongRunning { | |
private final Worker worker; | |
public static void main(String[] args) { | |
new LongRunning(new Worker()).doWork(); | |
} | |
public LongRunning(Worker worker) { | |
this.worker = worker; | |
} | |
private void doWork() { | |
new Thread(() -> { | |
while (true) { | |
worker.invoke(); | |
try { | |
Thread.sleep(1000L); | |
} catch (InterruptedException e) { | |
break; | |
} | |
} | |
}).start(); | |
} | |
} | |
class Worker { | |
public void invoke() { | |
System.out.println("Date is" + new Date()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment