Java: Threads

Contributor Icon Contributed by William_Wilson Date Icon May 12, 2006  
Tag Icon Tagged: Java programming

How to implement your own dynamic class threads, and run them.


simply copy the 2 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 it’s 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.*/

Questions/Comments: william_a_wilson@hotmail.com
-William. ยง (marvin_gohan)

Previous recipe | Next recipe |
 
blog comments powered by Disqus