Tuesday, May 29, 2018

Thread Ordering Without Using Synchronized [Snippet]

Say we have a requirement that thread 0 will print 0, thread 1 will print 1, thread 2 will print 2, etc. The following should be the output.

thread 0 prints 0
thread 1 prints 1
thread 2 prints 2
thread 3 prints 3
thread 0 prints 0
thread 1 prints 1
thread 2 prints 2
thread 3 prints 3
thread 0 prints 0
thread 1 prints 1
thread 2 prints 2
thread 3 prints 3




from DZone.com Feed https://ift.tt/2xnxPFk

No comments:

Post a Comment