What about creating an Action that spawns a new thread for the doPerform
action?
public class ThreadedAction extends Action implements Runnable
{
public void abstract doPerform();
public void perform()
{
Thread t = new Thread(this);
t.start();
}
public void run()
{
doPerform();
}
}
usage:
public class MyAction extends ThreadedAction
{
public void doPerform()
{
while ( time < VERYLONGTIME )
{
doSomeStuff();
}
}
}
There are probably some issues with the RunData object.
I would not personally use this for sending e-mail. I have never had any
issues with the time that takes. But that's abit off. If this mail is
stupid, sorry, I'm hung over.
>
-----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Youngho Cho
> Sent: 27. januar 2001 04:31
> To: Turbine
> Subject: [Proposal] SendEmail by a Thread
>
>
> Hi,
>
> Sending Email is sometimes take a few seconds.
> So I propose the treatment of the sending work by thread.
>
> In order to do that we need Actable interface and ActionWorker
>
>
> package org.apache.turbine.util;
>
> public interface Actable
> {
> public void doAction() throws Exception;
> }
>
>
> package org.apache.turbine.util;
>
> public class ActionWorker implements Runnable
> {
> private Actable actor = null;
>
> public ActionWorker( Actable actor)
> {
> this.actor = actor;
> }
>
> public void run()
> {
> try {
> if( actor == null ) {
> return;
> }
> actor.doAction();
> }
> catch(Exception e)
> org.apache.turbine.util.Log.error ( "Error running a
> ActionWorker : " + e);
> }
> }
>
> }
>
>
> Email.java
> Line 85
> - public abstract class Email
> + public abstract class Email implements Actable
>
> Line 441
> - }
> + public void doAction () throws Exception
> + {
> + send();
> + }
>
> + }
>
> How to use
>
> Email email = new SimpleEmail();
>
> email.addTo(toaddress , "");
>
> email.setFrom(fromaddress, ");
>
> ActionWorker worker = new ActionWorker(email);
> Thread thread = new Thread(worker);
> thread.start();
>
>
> Thanks
>
> youngho
> Nn�������n��?��vry��Êry?㲮���n��
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]