Java static and thread safety or what to do

Posted by Parhs on Stack Overflow See other posts from Stack Overflow or by Parhs
Published on 2010-04-20T16:23:52Z Indexed on 2010/04/20 16:33 UTC
Read the original article Hit count: 359

Filed under:
|

I am extending a library to do some work for me. Here is the code:

public static synchronized  String decompile(String source, int flags,UintMap properties,Map<String,String> namesMap)
    {
        Decompiler.namesMap=namesMap;
        String decompiled=decompile(source,flags,properties);
        Decompiler.namesMap=null;
        return decompiled;

    }

The problem is that namesMap is static variable. Is that thread safe or not? Because if this code runs concurently namesMap variable may change. What can I do for this?

© Stack Overflow or respective owner

Related posts about java

Related posts about thread-safety