I have a thread that sleeps and then repaints the main screen. I launch the thread in the main screen class and i can then use getname to avoid relaunching, but in other places in the same class i get a null for the Thread??
Code:
class MainWindow extends MainScreen
{
private Font myfont;
private MyThread thread1;
MainWindow() {
super();
String thn = Thread.currentThread().getName();
if (thn == "scrpaint")
{
}
else
{
MyThread thread1 = new MyThread ("scrpaint");
System.out.println("Thread 1: "+ thread1.t.isAlive());
System.out.println("Thread name is " + thread1.t.getName());
}
but 5 lines down if I try to get the Thread name using
System.out.println("Thread name is " + thread1.t.getName());
- the Thread is Null?? and my app throws a null pointer exception
Any ideas why? I want to interrupt the thread and display another screen and then resume...