regarding Threads

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ushach
    New Member
    • Nov 2006
    • 17

    regarding Threads

    hi all,
    my sample code is like this.
    Code:
    public Classs X
    {
    int n[]=new int[10];
    public void Xdes()
    {
    Z z=new Z();
    z.Zdes(n);
    }
    public class Z
    {
    public void Zdes(n)
    {
    //3loops which iterare nearly 10000 time
    }
    }
    I want to call the method Zdes(n) by using run() method of thread class.
    I have wriiten the code as
    Code:
    public class Xdes() implements Runnable
    {
    int n[]=new int[10];
    Z z=new Z();
    t=new Thread(this,"H");
    t.start();
    }
    public void run()
    {
    z.Zdes(n);
    }
    But it is giving me Exception.How to avoid that?
    Is there any other way to write this code.
    Main idea is code in Zdes(n) should be added to a thread.
    Last edited by JosAH; May 5 '07, 06:28 AM. Reason: added [code] ... [/code] tags
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    What is the exact Exception that's being thrown? btw you'd better give your
    classes and methods descriptive names for readability reasons.

    kind regards,

    Jos

    Comment

    Working...