Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting thread info from sub-threads.



My question regarding static vs. non-static was because when "invoke()" is called the object holding the method is ignored as an argument for static methods, which made me wonder if possibly this somehow was preventing thread information from seaping upwards.

As an update, I created a new test method. All this method does is go into a long loop doing some Math calculations. In any case, this method, when executed via our scheme DOES show up as a thread in our thread list!!!! I don't get it. Am I looking at a bug?

What I can tell you about the real method we are trying to launch is that it creates an entirely new JFrame, and for all practical purposes could be considered to be a full program within another program. About the only thing that I think could make a thread appear to not be present is the fact that I call invokeAndWait() when creating the GUI.

Any and all help would be appreciated.

Thanks in advance.


Michael Hall wrote:


On Aug 21, 2006, at 1:56 AM, bsd5tu1 wrote:


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.


Mike Hall mikehall at spacestar dot net http://www.spacestar.net/users/mikehall http://sourceforge.net/projects/macnative





_______________________________________________
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
References: 
 >Getting thread info from sub-threads. (From: bsd5tu1 <email@hidden>)
 >Re: Getting thread info from sub-threads. (From: Michael Hall <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.