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 6995645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:03:22+00:00 2026-05-27T20:03:22+00:00

Just a quick one – I’m in the process of writing a Sega Master

  • 0

Just a quick one – I’m in the process of writing a Sega Master System emulator. The design thus far is that the GUI (JFrame subclass etc.) runs in the Event Dispatch Thread, via an EventQueue.invokeLater() call, and all the emulator functions run in a separate thread. From what I understand this is supposed to be good practice, as the EDT is supposed to initialise and update the GUI, with Swing not being thread-safe.

This leads me to a small question – the console runs in the separate thread (Z80, VDP, etc.) and the VDP (when I’ve finished it) will update a BufferedImage. As long as I mark this BufferedImage as ‘synchronized’, is it safe to then access it from the EDT (the GUI’s paint method in particular)? I ask this as otherwise I will have to put a lot of VDP logic into the paint method itself, and I’d rather not do this, as it will slow down the GUI overall.

Simple question I know, but I’m still getting used to pushing Java2D for decent speed animation. It is worth mentioning that right after the repaint() method is called in the logic thread, the logic thread will sleep until woken for the next frame pass, so I’m guessing there won’t be a performance hit from this design – am I right?

Many thanks,
Phil Potter

UPDATE I should have used better language – the VDP will be accessing the BufferedImage through a synchronized setter method and the EDT will be accessing it through a synchronized getter method.

  • 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-27T20:03:23+00:00Added an answer on May 27, 2026 at 8:03 pm

    I don’t think you need to make the setter and getter synchronized since they should only be accessed from EDT. So lets take a step back. You said that the getter will be accessed from EDT — so we are thread safe here. Now with the setter method will be run on the VDP — to handle this case we want to call invokeLater ( see example). Take look here for more info.

    Runnable updateAComponent = new Runnable() {
    
        public void run() { 
    //this will run in the EDT
    component.doSomething(); 
    
    }
    
    };
    //this will run in the VDP
    SwingUtilities.invokeLater(updateAComponent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just a quick one, hopefully. I've coded up this: <script> $(div.design-project).css('display', 'none'); function InsertContent(tid)
Just a quick one - I wrote a php script recently that dynamically creates
Just a quick one. I am trying to work it the next element that
just a quick one, are you aware of any wordpress form plugins that allow
Just a quick one about installing a PHP website, are there any tools out
Just a quick one: what are peoples thoughts on using Action delegates for public
I was writing a quick one-liner in GHCi and tried to compose sum with
Just a quick question. I have one XML and I was hoping to tranform
Just a quick question: In an OOP MVC application, one key principle is the
just a quick query about safe/unsafe states in Dijkstra's Banker's algorithm ... If one

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.