Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hai!
- This is my controller file
- static boolean checkflag = false;
- static Double dataValue = 0.0;
- static Cancellable timerCall = null;
- static Thread tt;
- static Thread ttt;
- static Promise<Result> promiseOfPIValue1 = null;
- public static Result index() {
- Promise<Double> promiseOfPIValue = registerListener();
- System.out.println("initial value :"+promiseOfPIValue.get());
- Promise<Result> promiseOfResult = null;
- if(promiseOfPIValue != null)
- {
- promiseOfResult = promiseOfPIValue.map(
- new Function<Double,Result>()
- {
- public Result apply(Double pi) throws Throwable {
- {
- System.out.println("PI value computed: " + pi);
- return ok("PI value computed: " + pi);
- }
- }
- }
- );
- timerCall.cancel();
- checkflag = false;
- }
- //return ok(index.render("Your new application is ready."));
- return Results.async(promiseOfResult);
- }
- private static Promise<Double> registerListener() {
- // TODO Auto-generated method stub
- System.out.println("Listener boolean value :"+checkflag);
- Promise<Double> pd = Akka.future(
- new Callable<Double>()
- {
- public Double call()
- {
- if (checkflag)
- {
- dataValue = 3.14;
- return dataValue;
- }
- else
- {
- dataValue = null;
- return dataValue;
- }
- }
- }
- );
- if(dataValue == null)
- {
- pd = null;
- System.out.println(Thread.currentThread().hashCode());
- //ping();
- timerCall = Akka.system().scheduler().schedule(
- Duration.create(0, TimeUnit.MILLISECONDS),
- Duration.create(10, TimeUnit.SECONDS),
- new Runnable() {
- public void run()
- {
- System.out.println(Thread.currentThread().hashCode());
- System.out.println("Scheduler is calling ...");
- if(ping())
- {
- index();
- }
- }
- });
- }
- return pd;
- }
- private static boolean ping() {
- // TODO Auto-generated method stub
- System.out.println("ping boolean value :"+checkflag);
- {
- if (checkflag)
- {
- timerCall.cancel();
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- public static Result changeValue()
- {
- checkflag = true;
- return ok("getit");
- }
- -------------------------------------------------
- This is my out :
- PI value computed: null
- when i run this method changeValue();
- PI value computed: 3.14
- ---------------------------------------------------
- here
- list of return type method.
- 1. index ()
- 2. registerListener()
- 3. ping()
- 4. changeValue()
- My index method should not be returned null value ? is it possible? then help me.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement