1 7 8 package com.sun.corba.se.impl.activation; 9 10 import java.util.*; 11 import com.sun.corba.se.impl.orbutil.ORBConstants; 12 13 21 public class ProcessMonitorThread extends java.lang.Thread { 22 private HashMap serverTable; 23 private int sleepTime; 24 private static ProcessMonitorThread instance = null; 25 26 private ProcessMonitorThread( HashMap ServerTable, int SleepTime ) { 27 serverTable = ServerTable; 28 sleepTime = SleepTime; 29 } 30 31 public void run( ) { 32 while( true ) { 33 try { 34 Thread.sleep( sleepTime ); 38 } catch( java.lang.InterruptedException e ) { 39 break; 40 } 41 Iterator serverList; 42 synchronized ( serverTable ) { 43 serverList = serverTable.values().iterator(); 46 } 47 try { 48 checkServerHealth( serverList ); 49 } catch( ConcurrentModificationException e ) { 50 break; 51 } 52 } 53 } 54 55 private void checkServerHealth( Iterator serverList ) { 56 if( serverList == null ) return; 57 while (serverList.hasNext( ) ) { 58 ServerTableEntry entry = (ServerTableEntry) serverList.next(); 59 entry.checkProcessHealth( ); 60 } 61 } 62 63 static void start( HashMap serverTable ) { 64 int sleepTime = ORBConstants.DEFAULT_SERVER_POLLING_TIME; 65 66 String pollingTime = System.getProperties().getProperty( 67 ORBConstants.SERVER_POLLING_TIME ); 68 69 if ( pollingTime != null ) { 70 try { 71 sleepTime = Integer.parseInt( pollingTime ); 72 } catch (Exception e ) { 73 } 76 } 77 78 instance = new ProcessMonitorThread( serverTable, 79 sleepTime ); 80 instance.setDaemon( true ); 81 instance.start(); 82 } 83 84 static void interruptThread( ) { 85 instance.interrupt(); 86 } 87 } 88 89 | Popular Tags |