Can you configure Windows to open JAR files like ZIP files without a 3rd party tool?
500
Solution 1
I tried exporting HKEY_CLASSES_ROOT\.zip, changing all references of '.zip' to '.jar' and importing it to HKEY_CLASSES_ROOT\.jar.
Under Vista at least it let me open a .jar file as if it were a .zip.
Solution 2
What you need to do is associate the JAR extension in Windows Explorer with Compressed folders. From Windows Explorer select tools / Folder Options. Then the Files Types tab. Select New and associate JAR Compressed (ZIP) Folder.
Related videos on Youtube
Author by
user1445850
Updated on September 17, 2022Comments
-
user1445850 over 1 year
Can someone please let me know why is the below code not threadsafe ? The output I get is either 0 or 45 or 90. The shared resource counter has a synchronized method, so I am expecting 90 as the output all the times. Am I missing something here ? Please advise. Kindly, also let me know how to make this code threadsafe.
class Counter{ long count = 0; public synchronized void add(long value){ this.count += value; } } class CounterThread extends Thread{ protected Counter counter = null; public CounterThread(Counter counter){ this.counter = counter; } public void run() { for(int i=0; i<10; i++){ counter.add(i); } } } public class Example { public static void main(String[] args){ Counter counter = new Counter(); Thread threadA = new CounterThread(counter); Thread threadB = new CounterThread(counter); threadA.start(); threadB.start(); System.out.println(counter.count); } }
-
Eugen Martynov over 11 yearsRead about visibility jeremymanson.blogspot.nl/2007/08/…. Maybe I'm wrong
-
JohnB over 11 years@Eugen: Hm, probably you are right. Making count volatile should help as well (with visibility, not with the original question), shouldn't it?
-
user1445850 over 11 yearsI tried making the variable volatile, it does not work. The output again can be 0 or 45 or 90. Thread.join seems to be a perfect solution.
-
user1445850 over 11 yearsI tried sleeping the main thread & I got the output as 90. The fact that there are 3 threads here, was causing the confusion.
-
JohnB over 11 yearsVolatile, of course, does not solve your issue. You should, however, make count volatile in addition, for the reason pointed out by Eugen.