Skip to content

Instantly share code, notes, and snippets.

@nitsanw
Created March 21, 2016 09:26
Show Gist options
  • Save nitsanw/fe9d5db85d035ecb331b to your computer and use it in GitHub Desktop.
Save nitsanw/fe9d5db85d035ecb331b to your computer and use it in GitHub Desktop.
public static void main(String[] args) throws InterruptedException {
SampleLinkedQueue<Integer> q = new SampleLinkedQueue<>();
q.offer(1);
System.gc(); // N0, N1 are promoted
Thread.sleep(100);
q.poll(); // queue is empty, N0 is dead, N1 is alive
while(true) {
for (int i = 0; i < 4096; i++) {
// queue size is kept at 0, but new nodes are created
q.offer(1);
q.poll();
}
// slow the test down so we can observe with tools of our choice
Thread.sleep(100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment