Jump to content
  • Advertisement
Sign in to follow this  
dual_horizons

Java question: Multithreading in applets

This topic is 3920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am struggling to implement two or more threads in an applet. I mean, how can I call the run() of both of them, separately? Sorry if I am being an utter idiot, but I have the deadline of a java project submission is drawing near and I am going crazy! In case you would like to know, I am trying to create a game. Simple stuff (or so I thought). The PC shoots the NPC and both of them move around. I am creating a class that extends Applet. And creating a child thread in it to move the PC around. But I wish to have another thread to move the NPC, how can I? I can post the code, in case you'd like. Thanks, in advance.

Share this post


Link to post
Share on other sites
Advertisement

class Foo implements Runnable
{
public void run() {
// do the foo
}
}

Thread t1 = new Thread();
Thread t2 = new Thread( new Foo() );

t1.start(); // not run()
t2.start();


Quote:
I am creating a class that extends Applet. And creating a child thread in it to move the PC around. But I wish to have another thread to move the NPC, how can I?


Don't go thread-crazy.

So make a PC handler thread class, and NPC handler class (which will handle *all* NPCs).


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!