Comment #14 on issue 785 by [email protected]: Deadlock on "waitForValue"
http://code.google.com/p/google-guice/issues/detail?id=785

This'll do:

import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors

import com.google.inject.Guice
import com.google.inject.Inject
import com.google.inject.Injector


class GuiceHanging {

        static class Injected {
        }

        static class Parent {
                @Inject Injected injectedToParent
        }

        static class Child1 {
                @Inject Injected injectedToChild1
        }

        static class Child2 {
                @Inject Injected injectedToChild2
                @Inject Child1 child1InChild2
        }

        static void main(String[] args) {
                Injector injector = Guice.createInjector()
                List<Runnable> toRun = []
                1000.times { int i ->
                        toRun << {
                                ->
                                println("Injecting members to Child1 #${i+1} > 
START")
                                injector.injectMembers(new Child1())
                                println("Injecting members to Child1 #${i+1} > 
END")
                        } as Runnable
                        toRun << {
                                ->
                                println("Injecting members to Child2 #${i+1} > 
START")
                                injector.injectMembers(new Child2())
                                println("Injecting members to Child2 #${i+1} > 
END")
                        } as Runnable
                }
                ExecutorService executor = Executors.newCachedThreadPool()
                try {
                        executor.invokeAll(toRun)*.get()
                        println("Successfully executed all the injections")
                } finally {
                        assert !executor.shutdownNow()
                }
        }
}


--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice-dev.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to