Oct
08
|
Create a new Instance of Thread and call its start() method to start it.
You give the Thread constructor some instance that implements the Runnable interface. Once started the Thread will call the Runnable instances run() method is a separate thread.
Thread thread = new Thread(new Runnable() { public void run() { // this will be run in a separate thread doSomething(); } }); // start the thread thread.start();
Array ( ) One Response to “How do I execute a method in a new thread using Java?”
Leave a Reply
You must be logged in to post a comment.
March 28th, 2013 at 4:52 pm
thanks, it is exactly what i was looking for