Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6647209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:30:37+00:00 2026-05-26T00:30:37+00:00

Ok, so I am making a 2D game, and all the map is represented

  • 0

Ok, so I am making a 2D game, and all the map is represented in a 2D Array. I have this huge methods that modifies the map based on what is already in the map. So after a while implementing features, the FPS is lowering, so I decided to try to use multiple threads to make it faster ( Good thing, no? ).

I made 3 Threads to do the work, one that paints and handles Events, one that updates the base part of the map and the other updates another set of variables. The problem is, it paints but it does not update when I start all 3 Threads. It does update when I call the methods from the painting thread. I tested the first updating thread by adding “System.exit(0);” at the run, and it did not started when it otherwise would start. I also tried to manually change a tile of the map directly in the run method of the Updating thread, but it did nothing. So I concluded the run is executed, and the variables are modified. So I thought that maybe the variables used by the painter aren’t the updated ones.

All the variables are in a seperated class and are static ( Was that right? ) and were accessed by an object, but then I changed it to ‘Direct’ Access ( IDE Suggestion ) with the code “nameOfTheClass.variableName”

Almost forgot to mention, the Events ( In the class with the paint() method ) modifies the Map, and this part does work.

I don’t know what to do, anyone got an idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:30:38+00:00Added an answer on May 26, 2026 at 12:30 am

    I believe the problem is a race condition instead. The variable modification may be ‘delayed’ (by a few hundred nanoseconds?) as other accesses go through, but it will still happen, eventually. In this case, I don’t think volatile or anything like that will make a difference, since the ordering of thread syncs should not be important. If it is, you have bigger things to worry about. Also, I think your terminology might be a bit messed up –I can’t really understand the threading issue in relation to your code.

    If you need hard synchronisation, you can establish resource ‘fences’ (synchronization blocks) and keep your resource accesses within these fences, so that race conditions cannot occur. You establish transactions by nature of the fact that nothing can get into the fence while you are operating on these variables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a game for class and for this game I have an array
I'm making this game where I'm trying to pair people. So I have this
I am making a game that needs a crosshair. I have been playing with
I am making a game that I want compatible for all older devices to
I'm making a game where all movement is grid based. I also wan't to
I'm making a game with cocos2d and I have a bunch of sprites that
I am making a game for my CS class and the sprites I have
I'm making a game where each Actor is represented by a GameObjectController . Game
Although the context of this question is about making a 2d/3d game, the problem
I'm making a game in flash, and I want to have a whole bunch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.