Access properties of the class passed to a thread
Hi You all,
I have the following code:
package com.services;
import java.util.*;
publicclass Timerimplements Runnable
{
//-
//CLASS OBJECTS
//-
privateint interval;
privatevolatileint clockFlag = 0;
//-
//CONSTRUCTOR
//-
public Timer()
{
}
//-
publicvoid stop()
{
this.interval = 0;
}
//-
publicvoid setInterval(int pInterval)
{
this.interval = pInterval + 100000000;
}
//-
publicvoid run()
{
while(this.interval != 0)
{
if(this.clockFlag == this.interval)
{
System.out.println("clockFlag");
this.clockFlag = 0;
}
this.clockFlag ++;
}
}
}
Timer objTimer =new Timer();
objTimer.setInterval(5);
Thread objThread =new Thread(objTimer);
objThread.start();
So if I want to use the run method of the Timer class what should I do?
Is there any method in the thread that alows me to call any method of the class passed to it?
Thanks,
MeTitus

