Best way of creating and using an anonymous Runnable class

As the others have mentioned, using the Thread class is the correct way. However, you should also look in to using Javas Executors framework to handle running threads.

Executors.newSingleThreadExecutor().execute(new Runnable() {
    @Override 
    public void run() {
        // code in here
    }
});

Of course, just using Thread directly is fine. But it is generally advised (or preferred) to use the framework. Let Java handle the fine details for you.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)