Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Global unsynchronized data with multiple threads

 
Kaustubha Raut
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am doing a project to study semaphore. We are required to implement the bakery algorithm, where multiple threads work on the same global data and still achieve mutual exclusion. I have worked with C++ and its usually easy to implement global variables there. I know for a fact that java discourages global data.

My Question:

What is the best way to implement global data in this case? singletons, statics or somthing else. Please consider that I do NOT want the data to by synchronized be itself or its implementation.(Since the idea to to implement semaphores on my own.)

Thanks.
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the point of the exercise is to study synchronization, I would say that the way you store the data is completely irrelevant.
 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!