Java: Threads

Posted May 12, 2006 by William_Wilson in Java programming

Last Updated on

In this tech-recipe, you will learn how to implement your own dynamic class threads and run them.

Simply copy the two code segments, and replace the //thread code with your desired code to thread.

//private Thread class:

private class ThreadMyProg implements Runnable{
public void run(){
//thread code

//how to call this class and run it:

ThreadMyProg aThread = new ThreadMyProg();
new Thread(aThread).start();

This code is generated dynamically, but stores a single copy of the thread class to be re-used upon its need. You can take this a step further and implement a stack to create multiple copies of this method, thus taking advantage of threads to the fullest extent.*/

Questions/Comments: [email protected]
-William. ยง (marvin_gohan)

The Conversation

Follow the reactions below and share your own thoughts.

Leave a Reply