checking if variable is blank after 20 seconds
Code:
public class Test {
public static void main(String[] args) {
long startTime = System.nanoTime();
String blah = "";
while(true) {
System.out.println("testing");
if (System.nanoTime() - startTime > 20000)
break;
}
}
}
i want to somehow check if blah.equals("") after 20 seconds, can anyone help me?
Re: checking if variable is blank after 20 seconds
Code:
public static void main(String[] args)
{
String blah = "";
Thread th = new Thread(new Runnable()
{
@Override
public void run()
{
try
{
Thread.sleep(20000);
}
catch (InterruptedException e)
{
}
}
});
th.start();
}
Re: checking if variable is blank after 20 seconds
Of course it won't make any sense to do that for a local variable
Re: checking if variable is blank after 20 seconds
Thanks ComputerJy, but where would i check to see if blah still is "" after 20 seconds? after the Thread.sleep line?
Re: checking if variable is blank after 20 seconds