If the method we launch creates another thread within it,
How is it doing this? One thing you might do is subclass Thread and
then you can add whatever additional functionality you want to the
new class.
e.g.
public void start() {
ThreadTracker.put(this.getName(),"started"); // Or ThreadTracker.put
(getName(),getThreadInfo("started")); if more involved
super.start();
}
It sounds like possibly you aren't actually creating a new thread.
static has nothing to do with whether or not something changes. It
refers to whether a field or method applies to each instance of a
class or to the single instance of the class itself.
e.g.
public class CounterClass {
static int counter = 1;
increasing this to 2 increases it for the class itself, meaning every
instance of the class would now have the 2 value. Get rid of the
static and you increase it only for the current instance, every other
instance could have their own independent value.
A static method again applies to the whole class and not to each
single instance.
You need a static method say to change a static field...
public static void increment() { counter++; }
Because static applies to the class is why when you start
synchronizing threads with the method modifier
public synchronized static void increment() { counter++; }
you hold the lock on CounterClass.class
While if it's not static
public synchronized void increment() { counter++; }
you hold the lock only for this single instance of a CounterClass
Which would be pretty much how static applies to Threading.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden