java: communication between threads

Posted by TRU7H on Stack Overflow See other posts from Stack Overflow or by TRU7H
Published on 2012-06-10T16:29:54Z Indexed on 2012/06/10 16:40 UTC
Read the original article Hit count: 174

I'm making a little java game in which I would have two threads (well as the FIRST step towards multithreading...), one for the logic and one for the drawing.

So my question is: How can I make those two communicating which each other?

Requirements:

  • accessing variables and object from a another thread

  • syncing them so they each complete a same number of "loops" in the same time. (the logic calculates and then the another one draws the results and the loop begins again...)

So how is this achievable in java?

Thanks in advance!

© Stack Overflow or respective owner

Related posts about java

Related posts about multithreading