probably i need to explain better the problem, but first I'll try again implementing Runnable...

if you have some examples... thanks

:-)

On 24/feb/09, at 19:17, Chuck Hill wrote:

We don't have enough information to know what is wrong.


On Feb 24, 2009, at 9:21 AM, Amedeo Mantica wrote:

Following the example I tried to do the same in the Session, but It doesn't work, so I removed... :-)

and asked :-)

Amed


On 24/feb/09, at 18:10, Chuck Hill wrote:


On Feb 24, 2009, at 8:59 AM, Amedeo Mantica wrote:

actually I did'n touch the Session

You said, "I have created a subclass indide the Session that extends Thread". How did you start that?

Chuck


On 24/feb/09, at 17:50, Chuck Hill wrote:


On Feb 24, 2009, at 2:44 AM, Amedeo Mantica wrote:

I was looking at the LongResponseExample.java in the AjaxExample....

as you can see i the component ther is a subclass called Tast that extends Thread

and this works great, I can navigate to other webpagrs while task is running.


So, I have created ( probably badly ) a subclass indide the Session that extends Thread, it works, but i cannot navigate pages while running.

Suggestions?

Not without seeing what you did in session. There is NO reason that this needs to be a static inner class. Most of my runnables are separate classes.

Chuck



// Generated by the WOLips Templateengine Plug-in at 07.08.2006 16:32:09

import org.apache.log4j.Logger;

import com.webobjects.appserver.WOActionResults;
import com.webobjects.appserver.WOComponent;
import com.webobjects.appserver.WOContext;

public class LongResponseExample extends WOComponent {

        static Logger log = Logger.getLogger(LongResponseExample.class);

        public static class Task extends Thread {
                int stage = 0;
                String status = "Idle";

                public void run() {

                        try {
                                setStatus("Starting up");
                                sleep(2000);
                                while (stage < 20) {
                                        sleep(1000);
                                        stage++;
                                        setStatus("Currently at stage: " + 
stage);
                                }
                                setStatus("Finished");
                        }
                        catch (InterruptedException e) {
                                status = "Interrupted";
                        }
                }

                private void setStatus(String value) {
                        status = value;
                        log.info(status);
                }

                public String getStatus() {
                        return status;
                }
        }

        public Task task;

        public LongResponseExample(WOContext context) {
                super(context);
        }

        public long test() {
                return System.currentTimeMillis();
        }

        public WOComponent startTask() {
                task = new Task();
                task.start();
                return null;
        }

        public WOActionResults stopTask() {
                task.interrupt();
                return null;
        }
}



On 23/feb/09, at 22:36, Chuck Hill wrote:


On Feb 23, 2009, at 1:32 PM, Mike Schrag wrote:

Actually I'm able to do it only if i create a subclass that extends Thread in the component that will start it.

I don't understand why that is necessary. What happens if you don't do this?
random pet peeve btw ... you should never extend Thread. you're not a thread, you're a thing a thread runs ... you should implement Runnable.


Truth.  And a mistake I have made several times in the past.

Chuck


--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobjects- [email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/amedeomailing%40insigno.it

This email sent to [email protected]



--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects










--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects










--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects








_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to