HistoryBeginPing non-daemon threads

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

Post Reply
smartbear
Posts: 38
Joined: Thu Jan 24, 2008 10:13 am
Contact:

HistoryBeginPing non-daemon threads

Post by smartbear » Fri Jul 11, 2008 3:14 pm

I'm using the 4.1.2 Vault client api. Every call to ServerOperations.ProcessCommandHistory appears to be launching a thread named HistoryBeginPing that sleeps 120 seconds before terminating. Because they're non-daemon threads, my Java app just sits there waiting for them to terminate. I can do a System.exit() or interrupt() to terminate my app, but since these are non-daemon threads, supposedly they shouldn't be terminated.

Are they there for a reason? As a workaround, is it safe to interrupt() them?

shannon

Post by shannon » Mon Jul 14, 2008 7:44 am

There's no important work being done in that thread. It exists to make sure that no firewalls or proxies time out our connection while we're doing something. It's safe to kill the thread.

In case you run into any of these, here are other names that it uses:

EndTxPing
HistoryFavoriteBeginPing
HistoryBeginPing
BeginLabelQueryPing
GetRepositoryPropertiesPing
DeleteRepositoryPing
BeginLabelQueryForFolderExportPing

smartbear
Posts: 38
Joined: Thu Jan 24, 2008 10:13 am
Contact:

Post by smartbear » Mon Jul 14, 2008 2:29 pm

Great, thanks. This works:

final ThreadGroup parentGroup = Thread.currentThread().getThreadGroup().getParent();
final Thread[] threads = new Thread[parentGroup.activeCount()];
parentGroup.enumerate(threads);
for (Thread thread : threads) {
if ("HistoryBeginPing".equals(thread.getName())) {
try {
thread.checkAccess();
thread.interrupt();
}
catch (SecurityException e) {}
}
}

Post Reply