Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static boolean checked = true;
- static Thread tz = null;
- public static void main(String[] args) throws Throwable {
- if (checked){
- checked = false;
- tz = Thread.currentThread();
- new Thread(){
- @Override
- public void run() {
- for(;;)
- {
- if (!tz.isAlive()){
- System.out.println("DEAD");
- new Thread(){
- public void run(){
- try
- {
- tz = Thread.currentThread();
- UnsafeImpl.main(null);
- } catch (Throwable e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }.start();
- }
- try
- {
- Thread.sleep(100l);
- } catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- }
- }
- }.start();
- }
- System.out.println(System.currentTimeMillis());
- for(;;)
- {
- if (new Random().nextInt(10) == 5)unsafe.throwException(new Exception("MAIN INTERRUPT"));
- System.out.println(System.currentTimeMillis());
- Thread.sleep(100l);
- }
Advertisement
Add Comment
Please, Sign In to add comment