#Multithreading

17 messages ยท Page 1 of 1 (latest)

livid prairie
#

When dealing with multiple threads, is it better to extend the Thread class or implement Runnable?

inner wrenBOT
#

โŒ› This post has been reserved for your question.

Hey @livid prairie! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

torn night
#

I'd say Runnable, bc you can inherite from only one class but you can implement a lot of interfaces

#

But in general there is no better or worse option as far as i know

livid prairie
torn night
#

Or was that a question?Huh

livid prairie
torn night
#

Okay ๐Ÿ˜‚

torn night
# livid prairie It is a question hahaha

Consider this to be your class implementing Runnable:

public class TheRizzler implements Runnable {
    //Write fields, constructors, methods, whatever
    public void run() {
        //Write what your Thread should run, for example:
        System.out.println("Hawk Tuah Skibidi");
    }
}

Now later in your code you can execute your Thread, that is the run method you defined in your Runnable implementation, like this:

TheRizzler sigma = new TheRizzler();
Thread ohio = new Thread(sigma);
ohio.start();
inner wrenBOT
#

๐Ÿ’ค Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

limpid sapphire
#

Brainrot-infused coding tips ๐Ÿ˜…

#

Also please note Java naming conventions: It should be class TheRizzler.

torn night
inner wrenBOT
#

๐Ÿ’ค Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.