Hi,
What is the difference between the "usual" java objects vs Thread
objects? Are Thread objects actually sharing object/instance variables, as
compare to usual object where each object holds their object variable. I
did some experiement, it seem I can't access into thread object variables,
hence it seems thread objects share object/instance variables? For example,
i can invoke setInt() method of this thread object:
private static class MessageLoop implements Runnable {
int id = 0;
public void setInt(int id){
this.id = id;
}
public void run() {
String importantInfo[] = {
"Mares eat oats",
"Does eat oats",
"Little lambs eat ivy",
"A kid will eat ivy too"
};
try {
for (int i = 0; i < importantInfo.length; i++) {
//Pause for 4 seconds
Thread.sleep(4000);
//Print a message
threadMessage(importantInfo[i]);
}
} catch (InterruptedException e) {
threadMessage("I wasn't done!");
}
}
}
Regards
KC
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en