Added basic thread based clustering to java implementation