Search Results

Search found 4 results on 1 pages for 'jmm'.

Page 1/1 | 1 

  • Is it already possible to enable Compiz on an i5 Thinkpad laptop?

    - by jmm
    Besides a number of other issues, I still cannot enable Compiz or any effects with Maverick on a Thinkpad X201. I understand this laptop is supported by Ubuntu, yet I have found a good number of posts reporting problems. I would like to know if they have been solved by now. Processor: 4x Intel(R) Core(TM) i5 CPU M 540 @ 2.53GHz Intel Corporation Core Processor Integrated Graphics Controller (rev 02) OpenGL Renderer Mesa DRI Intel(R) Ironlake Mobile GEM 20100330 DEVELOPMENT 2.6.35-27-generic #47-Ubuntu SMP Thanks for your help, jmm

    Read the article

  • How can CopyOnWriteArrayList be thread-safe?

    - by Shooshpanchick
    I've taken a look into OpenJDK's sources of CopyOnWriteArrayList and it seems that all write operations are protected by the same lock and read operations are not protected at all. As I understand, under JMM all accesses to a variable (both read and write) should be protected by lock or reordering effects may occur. For example, set(int, E) method contains these lines (under lock): /* 1 */ int len = elements.length; /* 2 */ Object[] newElements = Arrays.copyOf(elements, len); /* 3 */ newElements[index] = element; /* 4 */ setArray(newElements); The get(int) method, on the other hand, only does return get(getArray(), index);. In my understanding of JMM, this means that get may observe the array in an inconsistent state if statements 1-4 are reordered like 1-2(new)-4-2(copyOf)-3. Do I understand JMM incorrectly or is there any other explanations on why CopyOnWriteArrayList is thread-safe?

    Read the article

  • How do I create a thread-safe write-once read-many value in Java?

    - by Software Monkey
    This is a problem I encounter frequently in working with more complex systems and which I have never figured out a good way to solve. It usually involves variations on the theme of a shared object whose construction and initialization are necessarily two distinct steps. This is generally because of architectural requirements, similar to applets, so answers that suggest I consolidate construction and initialization are not useful. By way of example, let's say I have a class that is structured to fit into an application framework like so: public class MyClass { private /*ideally-final*/ SomeObject someObject; MyClass() { someObject=null; } public void startup() { someObject=new SomeObject(...arguments from environment which are not available until startup is called...); } public void shutdown() { someObject=null; // this is not necessary, I am just expressing the intended scope of someObject explicitly } } I can't make someObject final since it can't be set until startup() is invoked. But I would really like it to reflect it's write-once semantics and be able to directly access it from multiple threads, preferably avoiding synchronization. The idea being to express and enforce a degree of finalness, I conjecture that I could create a generic container, like so: public class WoRmObject<T> { private T object; WoRmObject() { object=null; } public WoRmObject set(T val) { object=val; return this; } public T get() { return object; } } and then in MyClass, above, do: private final WoRmObject<SomeObject> someObject; MyClass() { someObject=new WoRmObject<SomeObject>(); } public void startup() { someObject.set(SomeObject(...arguments from environment which are not available until startup is called...)); } Which raises some questions for me: Is there a better way, or existing Java object (would have to be available in Java 4)? Is this thread-safe provided that no other thread accesses someObject.get() until after it's set() has been called. The other threads will only invoke methods on MyClass between startup() and shutdown() - the framework guarantees this. Given the completely unsynchronized WoRmObject container, it is ever possible under either JMM to see a value of object which is neither null nor a reference to a SomeObject? In other words, does has the JMM always guaranteed that no thread can observe the memory of an object to be whatever values happened to be on the heap when the object was allocated.

    Read the article

  • For what purpose does java have a float primitive type?

    - by Roman
    I heard plenty times different claims about float type in java. The most popular issues typicaly regard to converting float value to double and vice versa. I read (rather long time ago and not sure that it's actual now with new JVM) that float gives much worse performance then double. And it's also not recommended to use float in scientific applications which should have certain accuracy. I also remember that when I worked with AWT and Swing I had some problems with using float or double (like using Point2D.Float or Point2D.Double). So, I see only 2 advantages of float over double: it needs only 4 bytes while double needs 8 bytes JMM garantees that assignment operation is atomic with float variables while it's not atomic with double's. Are there any other cases where float is better then double? Do you use float's in your applications? It seems to me that the only valuable reason java has float is backward compatibility.

    Read the article

1