Runnable and Thread

My Runnable!
anyhelp it only prints out the seconds not what i print out here

			LooterTimer timeTast1 = new LooterTimer(10, new Runnable(){

				@Override
				public void run() {
					System.out.println("200"); <-- I WANT THIS TO PRINT OUT!
				}

				
			});

LooterTimer

package my.tdl.managers;

public class LooterTimer implements Runnable{

	private int defaultSeconds;
	private int seconds;
	private boolean hasCompleted;
	private boolean running;
	
	private Thread thread;
	
	public LooterTimer(int seconds, Runnable runnable) {
		this.seconds = seconds;
		this.defaultSeconds = seconds;
		start();
	}

	@Override
	public void run() {
		if(!running){
			running = true;
		}
		
		while(running){
			if(seconds != 0){
				System.out.println(seconds+" seconds left!"); <-- already printing!
				seconds -= 1;
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
			
			if(seconds == 0){
				stop();
			}
		}
		
		
	}


	public void stop() {
		running = false;
		hasCompleted = true;
		seconds = defaultSeconds;
		thread.stop();
	}

	public void start() {
		running = false;
		hasCompleted = false;
		seconds = defaultSeconds;
		if(thread == null){
			thread = new Thread(this);
			thread.start();
		}
	}
	
	public boolean isRunning() {
		return running;
	}


	public boolean hasCompleted() {
		return hasCompleted;
	}

}

Wait, whoa. Why do you have a thread inside a Runnable?

You’re calling start upon the class’s runnable implementation, the object “thread” is never called because “start” is a function within the runnable interface.

could you tell me how to do this stuff xD never used threading that mutch xD give example on how to achieve this

You pass a Runnable instance to a constructor of a class implementing Runnable, and never store/use the argument. How’s the Thread going to find out about the instance, and execute it? That, and a dozen race conditions, which can be ignored for now, given the nature of the previous issue. You might take a step back and consider mastering the essentials of the java language instead of plowing through like this.

this is why jgo sucks balls everybody can just say “learn essentials” jesus…
instead of helping…

Sometimes it’s better to be direct. From the code you provided it’s pretty clear you’re in way over your head. It’s too early to mess with concurrency when you struggle with reference passing and concepts like implementing interfaces vs. using them. Most importantly, what you are trying to do (performing an action after a certain delay) should not be done with threads at all. All you need is to save a timestamp, compare it to the current time, and execute a task when a certain amount of time has elapsed - a few frames later.

This attitude won’t help you as a programmer, or as anything in life really.
I would say we are helping.

Riven is correct, timestamps are the way to go here, I even wrote a simple system for doing this here:

They say learn the essentials because you need to know the essentials before you can apply them. If you don’t know how to apply the basic concepts of the language, you’re going to have a hard time using it. Yes, people here help but they’re not going to hold your hand while you learn the Java language - if that’s what you want then you’re probably not going to find it here. On the other hand, once you start needing help with more advanced things (like the optimal game loop) it is a great help because of the combined experience and knowledge.

Then log out.

Riven gave you the answer, and if you didn’t understand it, you could have come back with a technical question asking for clarification. Instead, you’re throwing an internet tantrum about being told that you should take a step back and start with something simpler, which is true.

I was going to expand on what Riven said and break it down into more easily digestible pieces, but after seeing this, I think I’ll spend my time on more productive and receptive posters instead.

Good luck.

The fact your signature says you do “tutorials” scares me massively.

^ This.
To kind of put this into perspective, think of me (DarkCart) doing a series of tutorials on something like LWJGL. I don’t know the first thing about doing something like this (as of right now I can barely get a quad and triangle to render at the same time), so teaching people to try to do something I don’t know how to do myself is kind of, frankly, useless.