/* HoseMokie.java by Mark D. LaDue */ /* March 15, 1998 */ /* Copyright (c) 1996 Mark D. LaDue You may study, use, modify, and distribute this example for any purpose. This example is provided WITHOUT WARRANTY either expressed or implied. */ /* SurfinShield 2.0 for Windows NT 4.0 fails to stop this applet. */ import java.applet.*; import java.awt.*; import java.io.*; import java.util.*; public class HoseMokie extends java.applet.Applet implements Runnable { Thread stubborn; AudioClip annoy; public void init() { stubborn = null; annoy = getAudioClip(getCodeBase(), "Sounds/dingdong.au"); if (annoy != null) annoy.loop(); } public void start() { if (stubborn == null) { stubborn = new Thread(this,"stubborn"); stubborn.setPriority(Thread.MAX_PRIORITY); stubborn.start(); } } public void stop() {} public void run() { try { while (true) { // Let folks know that the applet is alive and kicking HangingAround(); try {stubborn.sleep(3900);} catch (InterruptedException e) {} } } catch (ThreadDeath td) {System.out.println("You can't get me that easily!");} // Resurrect the hostile thread in case of ThreadDeath finally { System.out.println("I'm back again!"); HoseMokie hm = new HoseMokie(); Thread reborn = new Thread(hm, "stubborn"); reborn.start(); } } public void HangingAround() { Frame littleWindow; String failure = "Watch SurfinShield Fail to Stop an Applet"; Random num_gen; int frames_per_cycle = 1; // When SurfinShield tries to stop the applet, change its behavior if (annoy == null) { frames_per_cycle = 100; failure = "Truly the Leader in Java Security"; } for (int win = 0; win < frames_per_cycle; win++) { num_gen = new Random(System.currentTimeMillis()); littleWindow = new Frame(failure); littleWindow.resize(400, 200); littleWindow.move(Math.abs(num_gen.nextInt() % 500) + 1, Math.abs(num_gen.nextInt() % 500) + 1); littleWindow.show(); System.out.println("You can't stop me!"); } } }