Examples of AtomicReference


Examples of java.util.concurrent.atomic.AtomicReference

  this.state = new AtomicReference(state);
}

public Atom(Object state, IPersistentMap meta){
  super(meta);
  this.state = new AtomicReference(state);
}
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicReference

    //  String hostname = null;
    private AtomicReference hostname;
    // Private constructor prevents instantiation from other classes
    private FormatGetHostName() {
        hostname = new AtomicReference();
        // Set IP to something, then invoke a thread to get the hostname itself, if the
        // thread takes time to complete (DNS is slow), the IP address will be used until
        // the thread completes (then the "hostname" should be used).
        hostname.set(getIp());
        Thread lThread = (new Thread("loggerFormatGetHostName") {
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicReference

                        throw new RuntimeException(e);
                    }
                }
            });

            final AtomicReference reference = new AtomicReference();
            final ICompletableFuture completableFuture = es.asCompletableFuture(future);
            completableFuture.andThen(new ExecutionCallback() {
                @Override
                public void onResponse(Object response) {
                    reference.set(response);
                    latch2.countDown();
                }

                @Override
                public void onFailure(Throwable t) {
                    reference.set(t);
                    latch2.countDown();
                }
            });

            latch1.countDown();
            latch2.await(30, TimeUnit.SECONDS);
            assertEquals("success", reference.get());

        } finally {
            executorService.shutdown();
        }
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicReference

                        throw new RuntimeException(e);
                    }
                }
            });

            final AtomicReference reference1 = new AtomicReference();
            final AtomicReference reference2 = new AtomicReference();
            final ICompletableFuture completableFuture = es.asCompletableFuture(future);
            completableFuture.andThen(new ExecutionCallback() {
                @Override
                public void onResponse(Object response) {
                    reference1.set(response);
                    latch2.countDown();
                }

                @Override
                public void onFailure(Throwable t) {
                    reference1.set(t);
                    latch2.countDown();
                }
            });
            completableFuture.andThen(new ExecutionCallback() {
                @Override
                public void onResponse(Object response) {
                    reference2.set(response);
                    latch2.countDown();
                }

                @Override
                public void onFailure(Throwable t) {
                    reference2.set(t);
                    latch2.countDown();
                }
            });

            latch1.countDown();
            latch2.await(30, TimeUnit.SECONDS);
            assertEquals("success", reference1.get());
            assertEquals("success", reference2.get());

        } finally {
            executorService.shutdown();
        }
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicReference

            });

            final ICompletableFuture completableFuture = es.asCompletableFuture(future);
            latch1.await(30, TimeUnit.SECONDS);

            final AtomicReference reference = new AtomicReference();
            completableFuture.andThen(new ExecutionCallback() {
                @Override
                public void onResponse(Object response) {
                    reference.set(response);
                    latch2.countDown();
                }

                @Override
                public void onFailure(Throwable t) {
                    reference.set(t);
                    latch2.countDown();
                }
            });

            latch2.await(30, TimeUnit.SECONDS);
            if (reference.get() instanceof Throwable) {
                ((Throwable) reference.get()).printStackTrace();
            }

            assertEquals("success", reference.get());

        } finally {
            executorService.shutdown();
        }
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicReference

                }
            });

            latch1.await(30, TimeUnit.SECONDS);

            final AtomicReference reference1 = new AtomicReference();
            final AtomicReference reference2 = new AtomicReference();
            final ICompletableFuture completableFuture = es.asCompletableFuture(future);
            completableFuture.andThen(new ExecutionCallback() {
                @Override
                public void onResponse(Object response) {
                    reference1.set(response);
                    latch2.countDown();
                }

                @Override
                public void onFailure(Throwable t) {
                    reference1.set(t);
                    latch2.countDown();
                }
            });
            completableFuture.andThen(new ExecutionCallback() {
                @Override
                public void onResponse(Object response) {
                    reference2.set(response);
                    latch2.countDown();
                }

                @Override
                public void onFailure(Throwable t) {
                    reference2.set(t);
                    latch2.countDown();
                }
            });

            latch2.await(30, TimeUnit.SECONDS);
            assertEquals("success", reference1.get());
            assertEquals("success", reference2.get());

        } finally {
            executorService.shutdown();
        }
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicReference

                    throw new RuntimeException(e);
                }
            }
        });

        final AtomicReference reference = new AtomicReference();
        final ICompletableFuture completableFuture = es.asCompletableFuture(future);
        completableFuture.andThen(new ExecutionCallback() {
            @Override
            public void onResponse(Object response) {
                reference.set(response);
                latch2.countDown();
            }

            @Override
            public void onFailure(Throwable t) {
                reference.set(t);
                latch2.countDown();
            }
        });

        latch1.countDown();
        latch2.await(30, TimeUnit.SECONDS);
        assertEquals("success", reference.get());
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicReference

                    throw new RuntimeException(e);
                }
            }
        });

        final AtomicReference reference1 = new AtomicReference();
        final AtomicReference reference2 = new AtomicReference();
        final ICompletableFuture completableFuture = es.asCompletableFuture(future);
        completableFuture.andThen(new ExecutionCallback() {
            @Override
            public void onResponse(Object response) {
                reference1.set(response);
                latch2.countDown();
            }

            @Override
            public void onFailure(Throwable t) {
                reference1.set(t);
                latch2.countDown();
            }
        });
        completableFuture.andThen(new ExecutionCallback() {
            @Override
            public void onResponse(Object response) {
                reference2.set(response);
                latch2.countDown();
            }

            @Override
            public void onFailure(Throwable t) {
                reference2.set(t);
                latch2.countDown();
            }
        });

        latch1.countDown();
        latch2.await(30, TimeUnit.SECONDS);
        assertEquals("success", reference1.get());
        assertEquals("success", reference2.get());
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicReference

            }
        });

        assertOpenEventually(latch1);

        final AtomicReference reference = new AtomicReference();
        final ICompletableFuture completableFuture = es.asCompletableFuture(future);
        completableFuture.andThen(new ExecutionCallback() {
            @Override
            public void onResponse(Object response) {
                reference.set(response);
                latch2.countDown();
            }

            @Override
            public void onFailure(Throwable t) {
                reference.set(t);
                latch2.countDown();
            }
        });

        assertOpenEventually(latch2);
        assertEquals("success", reference.get());
    }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicReference

            }
        });

        assertOpenEventually(latch1);

        final AtomicReference reference1 = new AtomicReference();
        final AtomicReference reference2 = new AtomicReference();
        final ICompletableFuture completableFuture = es.asCompletableFuture(future);
        completableFuture.andThen(new ExecutionCallback() {
            @Override
            public void onResponse(Object response) {
                reference1.set(response);
                latch2.countDown();
            }

            @Override
            public void onFailure(Throwable t) {
                reference1.set(t);
                latch2.countDown();
            }
        });
        completableFuture.andThen(new ExecutionCallback() {
            @Override
            public void onResponse(Object response) {
                reference2.set(response);
                latch2.countDown();
            }

            @Override
            public void onFailure(Throwable t) {
                reference2.set(t);
                latch2.countDown();
            }
        });

        assertOpenEventually(latch2);
        assertEquals("success", reference1.get());
        assertEquals("success", reference2.get());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.