class open extends Thread
{
String ag;
public void run()
{
System.out.println(" In Run method ");
String nam = getName();
System.out.println(nam);
ag = "$Z12J.#ZJMX";
open(ag);
}
Please use the CODE button; your posting is difficult to read.I think the problem is that although you have correctly initialised the array called obj, all its 10 references point to null until you assign them
Vinney Shanmugam
Ranch Hand
Joined: Aug 27, 2008
Posts: 104
posted
0
thanks for the replies..... Sure, from the next time i ll use the code BUTTON.
Vinney Shanmugam
Ranch Hand
Joined: Aug 27, 2008
Posts: 104
posted
0
Ernest Friedman-Hill wrote:You have to manually create the objects to put into the array; i.e,
Note that array indices go from 0 up to length-1; the first array element is not number 1, and the last is not at the array length!
Thanks.
i am able to run the program after making necessary changes..... one more doubt, now can i call this program as a multi threaded one, which spawns 10 threads???
You can make the program multi threaded just the way you originally did it, by calling the start() method of the thread object.
By the way, if your only intention is to use the class open as a multi-threaded one and not actually give it thread behavior you should implement the Runnable interface rather than extending the Thread class.
The only reason to extend the Thread class is when you are customizing the Thread class to add some functionality, which you shouldn't be generally doing.