1 14 15 package org.quickserver.util.io; 16 17 import java.io.*; 18 19 23 class MaskingThread extends Thread { 24 private volatile boolean stop; 25 27 30 public MaskingThread(String prompt) { 31 System.out.print(prompt); 32 } 33 34 37 public void run() { 38 int priority = Thread.currentThread().getPriority(); 39 Thread.currentThread().setPriority(Thread.MAX_PRIORITY); 40 41 try { 42 stop = true; 43 while(stop) { 44 System.out.print("\010 " ); 45 try { 46 Thread.currentThread().sleep(1); 48 }catch (InterruptedException iex) { 49 Thread.currentThread().interrupt(); 50 return; 51 } 52 } 53 } finally { Thread.currentThread().setPriority(priority); 55 } 56 } 57 58 61 public void stopMasking() { 62 this.stop = false; 63 } 64 } 65 | Popular Tags |