-1

I'm developing a java 2D game, with a Board class and Mob(s) class. The board class has a thread that calls 'repaint()' every a specified delay, while the mobs class constructs a new thread for each of the mob spawned, which means when it does something, it ticks its time on its own. Simply said, I seperate the thread to enable frame rate setting. So i just need to only set how long does the Board thread sleep, like faster sleep means more frame rate (I use threads for this because a site says threaded timing can be made real precise). But then it means in a crowded in-game situation there would be a lot of thread running from every active Mob there.

My question: if i have this lots of thread running at the same time, wouldn't it be consuming a lot of system resources? And if yes, what is the best way round so I don't need to use threads? (just to note 2D game "crowded" situation can be "really crowded").

Ganthet
  • 13
  • 5

1 Answers1

0

I think your question could resume to one of these :

Why is creating a Thread said to be expensive?

How expensive is creating of a new thread in Java? When should we consider using of a thread pool?

Is it expensive to create the Thread object or to actually start the thread?

etc...

Plenty of resource to find info on the subject.

what is the best way round so I don't need to use threads

This question is not appropriate for SO (too broad)

Community
  • 1
  • 1
Ronan Quillevere
  • 3,699
  • 1
  • 29
  • 44