B
billreyn
Someone please help me out, I've looked at 50+ books on Interfaces.
I understand contracts etc. But how on earth does an Interface method
do something like start a thread running? eg:
class TryThreads implements Runnable
{
public void run() {
for (int x = 1; x < 100; x++) { // runs a new thread
} }
Above is MY implementation of the Interface method run() (its not
exactly right, no matter), and it will run in its own thread. But I
have not written anything to do with running a thread, so how does it
'know' to do this special task? (running a thread)??? All I do is my
OWN implementation of run() which is just a 'for' loop. How does it
'know' to run it in its own thread?? According to every book I have
read, an Interface only forces me to write my own method with the
method name & params that is in the Interface. hat I understand, so how
does it run a thread? Its not in my implementation.
Will some kind person explain whats going on in simple English that
even I could understand.
I understand contracts etc. But how on earth does an Interface method
do something like start a thread running? eg:
class TryThreads implements Runnable
{
public void run() {
for (int x = 1; x < 100; x++) { // runs a new thread
} }
Above is MY implementation of the Interface method run() (its not
exactly right, no matter), and it will run in its own thread. But I
have not written anything to do with running a thread, so how does it
'know' to do this special task? (running a thread)??? All I do is my
OWN implementation of run() which is just a 'for' loop. How does it
'know' to run it in its own thread?? According to every book I have
read, an Interface only forces me to write my own method with the
method name & params that is in the Interface. hat I understand, so how
does it run a thread? Its not in my implementation.
Will some kind person explain whats going on in simple English that
even I could understand.