001    /*
002     * PrintDots.java
003     *
004     * Created on August 11, 2006, 1:30 PM
005     *
006     * This file is part of the STAR Scheduler.
007     * Copyright (c) 2002-2006 STAR Collaboration - Brookhaven National Laboratory
008     *
009     * STAR Scheduler is free software; you can redistribute it and/or modify
010     * it under the terms of the GNU General Public License as published by
011     * the Free Software Foundation; either version 2 of the License, or
012     * (at your option) any later version.
013     *
014     * STAR Scheduler is distributed in the hope that it will be useful,
015     * but WITHOUT ANY WARRANTY; without even the implied warranty of
016     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017     * GNU General Public License for more details.
018     *
019     * You should have received a copy of the GNU General Public License
020     * along with STAR Scheduler; if not, write to the Free Software
021     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022     */
023    
024    package gov.bnl.star.offline.scheduler.dataset.catalog;
025    
026    /**
027     * Allows a dots “.” to  be printed by separate thread.
028     *
029     * @author lbhajdu
030     */
031    public class PrintDots extends Thread  {
032        
033      
034        public static int delay = 5000; 
035        public static void pauseDots(){
036            //System.out.println("pauseDots()");
037            print = false;
038        }
039        public static void resumeDots(){
040            //System.out.println("resumeDots()");
041            print = true;
042            exit = false; 
043        } 
044        public void exitPrinting(){ 
045            //System.out.println("exitPrinting()");
046            exit = true; 
047        }
048        
049        private static boolean print = true;
050        private static boolean exit = false;
051    
052        public void run(){
053            
054            
055            while(! exit){
056                try {
057                    if(print) System.out.print(".");
058                    Thread.yield();
059                    Thread.sleep(delay);
060                } catch (InterruptedException ex) {
061                    ex.printStackTrace();
062                }
063            }
064        }
065        
066    
067        /** Creates a new instance of PrintDots */
068        public PrintDots()  {}
069        
070    }