Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Global unsynchronized data with multiple threads  RSS feed

 
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: 22185
38
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!