}
public void testActiveMonitorThreadSafety() throws CascadingAssertionFailedError
{
ComponentSelector selector = null;
Monitor activeMonitor = null;
try
{
selector = (ComponentSelector) manager.lookup( Monitor.ROLE + "Selector" );
activeMonitor = (Monitor) selector.select( "active" );
final Monitor monitor = activeMonitor;
getLogger().info( "Aquired Active monitor" );
for ( int i = 0; i < 500; i++ )
{
final int threadNum = i;
final Thread thread = new Thread() {
Resource resource = new FileResource( "testts-" + threadNum + ".txt" );
public void run()
{
while ( true )
{
monitor.addResource( resource );
monitor.removeResource( resource );
}
}
};
thread.start();
}