ServiceInstance si = new ServiceInstance(new URL("http://10.20.143.205/sdk"), "root", "password", true);
Folder rootFolder = si.getRootFolder();
ManagedEntity[] vms = new InventoryNavigator(rootFolder).searchManagedEntities("VirtualMachine");
ManagedEntity[] hosts = new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem");
CacheInstance vicf = new CacheInstance(si);
vicf.watch(vms, new String[] {"name", "runtime.powerState", "summary"});
vicf.watch(hosts, new String[] {"name", "summary"});
vicf.start();
//check if the caching is ready to use; otherwise wait
while(!vicf.isReady())
{
Thread.sleep(1000);
}
Thread[] vrs = new VimReader[2];