AnirbanDelhi Pal wrote:
Just for a try, I have not used any kind of object locking. Just uses a simple boolean variable just to denote either buffer is empty or full, based on that Producer writes or Consumer reads. And it worked. Why so ? Is not synchronisation has it's job to play in between ??
Thread safety just means that it will work correctly. The lack of thread safety means that it may not work correctly. It doesn't mean that it will definitely not work.
Try ...
1. Making the loop bigger.
2. Removing the sleep calls during each loop
3. On a different machine, with a different JVM version
3b. On a different machine, with a different processor or OS version
3c. On a different machine, with entirely different processors or operating system.
etc.
Henry