Reputation: 1
I am trying to create background music for a game that I am creating in java. I have the class running but when I implement it in the game and try to run it, the music and the actual game don't run at the same time. How do I make it so that the game and music will run at the same time?
Upvotes: 0
Views: 64
Reputation: 1270
As we can not see what you did it is hard to offer solutions. But in summary, the thing that you have to do is to create two threads in your application. One will run the task which is responsible of audio playing and the other will run the main game loop. Use a thread pool of size 2 and after creating the mentioned tasks above, run them at the same time by calling join.
Upvotes: 1