-2

Getting this error when calling another method and passing string parameter inside the thready run method....ERROR IS "Change modifier of titlePartnerF to final".. method which I am trying to call using for send push notifications which should be run in background. please help...Thanks in advance

String titlePartnerF= titlePartner; 
final MerchantBeanPush pushBeanF = pushBean ;
// MULTHREADING CODE 
// KAMLESH DAVE : 03-FEB-2019
Thread t = new Thread(new Runnable() {
    public void run() {
        /* * Do something inside the thread*/
        PushNotifictionHelper.sendPushNotification("W",pushBeanF.getWebToken(),titlePartnerF,messageP, bodyPartner);    
    }
});
t.start();
System.out.println("we are outside from method now in background+++++++++++");

enter image description here

Lino
  • 19,604
  • 6
  • 47
  • 65
kamlesh
  • 1
  • 1

1 Answers1

0

Any variable referred to within an inner class must be declared final or be effectively final.

String titlePartnerF= titlePartner; needs to be final String titlePartnerF= titlePartner;

Have a look at explanation here: Why Java inner classes require "final" outer instance variables?

user1717259
  • 2,717
  • 6
  • 30
  • 44