Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #4594
| From | Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.gui |
| Subject | Re: Synchronization when collecting data from the EDT? |
| Date | 2011-06-10 01:25 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <isrkq4$hkf$1@dont-email.me> (permalink) |
| References | (6 earlier) <islktt$kt1$1@dont-email.me> <nospam-1E20CE.13382907062011@news.aioe.org> <ism7lg$ku1$1@dont-email.me> <nospam-7E1CB5.23515607062011@news.aioe.org> <isrk9n$f4l$1@dont-email.me> |
On 10/06/2011 01:17, Daniele Futtorovic allegedly wrote:
> static <V> V invokeAndWait( final Callable<V> callable )
> throws InterruptedException
> {
> final Exchanger<V> x = new Exchanger<V>();
> EventQueue.invokeLater(
> new Runnable(){ @Override public void run() {
> try {
> x.exchange( callable.call() );
> }
> catch (InterruptedException iex ){
> Thread.currentThread().interrupt();
> }
> catch ( Exception e ){
> //exception in the callable. Blow shit up.
> throw new RuntimeException(e);
> }
> }}
> );
>
> return x.exchange( null );
> }
Realised one big mistake: the caller might block indefinitely.
Corrected version:
static <V> V invokeAndWait( final Callable<V> callable )
throws InterruptedException
{
final Exchanger<V> x = new Exchanger<V>();
EventQueue.invokeLater(
new Runnable(){ @Override public void run() {
try {
x.exchange( callable.call() );
}
catch (InterruptedException iex ){
//best effort
try { x.exchange( null ); } catch ( InterruptedException
iex2 ){}
Thread.currentThread().interrupt();
}
catch ( Exception e ){
//exception in the callable. Blow shit up.
try {
x.exchange( null );
throw new RuntimeException(e);
}
catch ( InterruptedException iex2 ){
Thread.currentThread().interrupt();
}
}
}}
);
return x.exchange( null );
}
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
Synchronization when collecting data from the EDT? Knute Johnson <nospam@knutejohnson.com> - 2011-06-04 17:38 -0700
Re: Synchronization when collecting data from the EDT? Knute Johnson <nospam@knutejohnson.com> - 2011-06-04 17:50 -0700
Re: Synchronization when collecting data from the EDT? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-06-05 17:52 +0200
Re: Synchronization when collecting data from the EDT? Knute Johnson <nospam@knutejohnson.com> - 2011-06-05 10:47 -0700
Re: Synchronization when collecting data from the EDT? "John B. Matthews" <nospam@nospam.invalid> - 2011-06-05 23:47 -0400
Re: Synchronization when collecting data from the EDT? Knute Johnson <nospam@knutejohnson.com> - 2011-06-05 22:11 -0700
Re: Synchronization when collecting data from the EDT? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-06-06 14:31 +0200
Re: Synchronization when collecting data from the EDT? "John B. Matthews" <nospam@nospam.invalid> - 2011-06-06 23:03 -0400
Re: Synchronization when collecting data from the EDT? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-06-07 18:51 +0200
Re: Synchronization when collecting data from the EDT? "John B. Matthews" <nospam@nospam.invalid> - 2011-06-07 13:38 -0400
Re: Synchronization when collecting data from the EDT? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-06-08 00:10 +0200
Re: Synchronization when collecting data from the EDT? "John B. Matthews" <nospam@nospam.invalid> - 2011-06-07 23:51 -0400
Re: Synchronization when collecting data from the EDT? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-06-10 01:17 +0200
Re: Synchronization when collecting data from the EDT? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-06-10 01:25 +0200
Re: Synchronization when collecting data from the EDT? "John B. Matthews" <nospam@nospam.invalid> - 2011-06-09 22:34 -0400
Re: Synchronization when collecting data from the EDT? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-06-10 05:22 +0200
Re: Synchronization when collecting data from the EDT? markspace <-@.> - 2011-06-10 08:04 -0700
Re: Synchronization when collecting data from the EDT? "John B. Matthews" <nospam@nospam.invalid> - 2011-06-10 21:13 -0400
Re: Synchronization when collecting data from the EDT? Knute Johnson <nospam@knutejohnson.com> - 2011-06-12 12:51 -0700
Re: Synchronization when collecting data from the EDT? markspace <-@.> - 2011-06-07 23:31 -0700
Re: Synchronization when collecting data from the EDT? Knute Johnson <nospam@knutejohnson.com> - 2011-06-08 23:07 -0700
Re: Synchronization when collecting data from the EDT? "John B. Matthews" <nospam@nospam.invalid> - 2011-06-09 18:35 -0400
Re: Synchronization when collecting data from the EDT? Knute Johnson <nospam@knutejohnson.com> - 2011-06-12 12:45 -0700
Re: Synchronization when collecting data from the EDT? Knute Johnson <nospam@knutejohnson.com> - 2011-06-08 23:05 -0700
Re: Synchronization when collecting data from the EDT? "John B. Matthews" <nospam@nospam.invalid> - 2011-06-09 14:35 -0400
Re: Synchronization when collecting data from the EDT? Roedy Green <see_website@mindprod.com.invalid> - 2011-06-05 13:39 -0700
Re: Synchronization when collecting data from the EDT? Knute Johnson <nospam@knutejohnson.com> - 2011-06-05 22:17 -0700
Re: Synchronization when collecting data from the EDT? markspace <-@.> - 2011-06-07 14:51 -0700
Re: Synchronization when collecting data from the EDT? markspace <-@.> - 2011-06-05 17:46 -0700
Re: Synchronization when collecting data from the EDT? Knute Johnson <nospam@knutejohnson.com> - 2011-06-05 22:41 -0700
Re: Synchronization when collecting data from the EDT? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-06-06 14:35 +0200
csiph-web