Multithreading
When dealing with multiple threads, is it better to extend the Thread class or implement Runnable?
10 Replies
⌛
This post has been reserved for your question.
Hey @DueShoulder! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose 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.
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
How come when you implement runnable you don't have to extend Thread
Yeah, that is the point^^
Or was that a question?:Huh:
It is a question hahaha
Okay 😂
Consider this to be your class implementing Runnable:
Now later in your code you can execute your Thread, that is the run method you defined in your Runnable implementation, like this:
💤
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.
Brainrot-infused coding tips 😅
Also please note Java naming conventions: It should be
class TheRizzler
.Fair
I'm so sad Java has no
#define
, there would be marvellous brainrot. I would mogg you all to Ohio.💤
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.