I have thread class that has two variables var1 and var2 that might be accessed from different threads. Can we assume that using var2 via synchronized getter and setter is the same like using volatile var1 without them?
public class Processor extends Thread
{
    public volatile  boolean var1 = false
    private boolean var2 = false
    synchronized boolean getVar2 ()
    {
        return var2;
    }
    synchronized boolean setVar2 (boolean value)
    {
        return var2=value;
    }
    public void run()
    {
        ...
    }
}
 
     
     
    