This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin 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: 22499
43
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!