ok so 2 cases:
- bug is in tomee when creating the thread -> Ill check it
- bug is due to your task as explained before, for this case you can do
something like:
@Singleton
public class MyAsyncService {
@Resource SessionContext ctx;
AtomicReference<Future<?>> future = new AtomicReference<>();
public Future<Void> doIt(){
future.set(ctx. getBusinessObject(MyAsyncService.class)
.doItAsync());
System.out.println("Done");
return null;
}
@Asynchronous
public void doItAsync(){
System.out.println("Doing it async");
}
@PreDestoy public void cancel()
{ofNullable(future).map(AtomicReference::get).ifPresent(Future::cancel);}
}
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>
2015-09-03 15:39 GMT+02:00 tonywestonuk <tonyw@totspics.com>:
> I am sorry, but I don't really understand how I can kill the task....
>
> In my example, above, the async task is just a single System.out !! -
> How
> can I kill this, it executes in milliseconds!!
>
> Looking at the threads using VisualVM, I can see the asynchronous thread in
> there, but it is marked as completed, and no longer running. there is no
> task to kill.... everything is done! It just needs to be removed from the
> ContextBindings to allow the old application to be GC'd.
>
> Or, if i am completely missing the point of what you are telling me, please
> feel free to show me how I can make my example MyAsyncService work so the
> app correctly undeploys.
>
> Thank you for helping..... :-D
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Permgen-issue-tp4676065p4676088.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>
|