Hello, I’m creating a text based/graphic rpg game and I’m using the follow method to print to my JTextPane. My question is, is this the right way to do it? I feel like something is wrong because I’m creating a new Thread everytime. Thanks
public void printMessage(final Game game, final String message, final int delay, final Color color)
{
Runnable run = new Runnable()
{
@Override
public void run()
{
long currentTime = System.currentTimeMillis();
boolean sent = false;
while(!sent)
{
if(System.currentTimeMillis() > currentTime + (delay * 1000))
{
game.printMessage(message, color);
sent = true;
}
}
}
};
Thread thread = new Thread(run);
thread.start();
}