for(int i=0; i<fields.size(); i++) {
FieldDescriptor fd=(FieldDescriptor)fields.get(i);
- if((fd.isStatic()) || (fd.isVolatile())) {
- // static/volatile field
+ if(fd.isStatic()) {
+ // static field
output.println(generateTemp(fm,fm.getParameter(0),lb)+"->"+fd.getSafeSymbol()+"=&(global_defs_p->"+cn.getSafeSymbol()+fd.getSafeSymbol()+");");
}
}
// DEBUG }
if(state.MGC) {
// TODO add version for normal Java later
- if((ffn.getField().isStatic()) || (ffn.getField().isVolatile())) {
+ if(ffn.getField().isStatic()) {
// static field
if((fm.getMethod().isStaticBlock()) || (fm.getMethod().isInvokedByStatic())) {
// is a static block or is invoked in some static block
// DEBUG }
if(state.MGC) {
// TODO add version for normal Java later
- if((fsfn.getField().isStatic()) || (fsfn.getField().isVolatile())) {
+ if(fsfn.getField().isStatic()) {
// static field
if((fm.getMethod().isStaticBlock()) || (fm.getMethod().isInvokedByStatic())) {
// is a static block or is invoked in some static block
-public class VolatileTest extends Thread {
- volatile int num;
- String name;
+public class VInt {
+ public int num;
- {
- num = 0;
+ public VInt() {
+ this.num = 0;
}
+}
+
+public class VolatileTest extends Thread {
+ volatile VInt vi;
+ String name;
- public VolatileTest(String name) {
+ public VolatileTest(String name, VInt vi) {
this.name = name;
+ this.vi = vi;
}
public void run(){
if(name.equals("Thread1")){
- num=10;
+ vi.num=10;
}
else{
- System.out.println("value of num is :"+num);
+ System.out.println("value of num is :"+vi.num);
}
}
public static void main(String args[]){
- Thread t1 = new VolatileTest("Thread1");
+ VInt vi = new VInt();
+
+ Thread t1 = new VolatileTest("Thread1", vi);
t1.start();
Thread.sleep(1000);
- Thread t2 = new VolatileTest("Thread2");
+ Thread t2 = new VolatileTest("Thread2", vi);
t2.start();
}
}
\ No newline at end of file