This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/jdk/src/share/classes/sun/misc/Unsafe.java b/jdk/src/share/classes/sun/misc/Unsafe.java | |
index 345f654..5b6b54a 100644 | |
--- a/jdk/src/share/classes/sun/misc/Unsafe.java | |
+++ b/jdk/src/share/classes/sun/misc/Unsafe.java | |
@@ -502,11 +502,41 @@ public final class Unsafe { | |
public native void setMemory(long address, long bytes, byte value); | |
/** | |
+ * alexkasko: reverting changes to match jdk7 signature | |
+ * http://hg.openjdk.java.net/jdk6/jdk6/jdk/diff/39e8fe7a0af1/src/share/classes/sun/misc/Unsafe.java |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LongPackUtils { | |
public static long pack(long big, int little, int bits) { | |
assert bits > 32 && bits < 64; | |
assert big < (1L << bits); | |
assert little < (1 << (64 - bits)); | |
int ls = bits % 8; | |
int bm = (1 << ls) - 1; | |
long res = (big & ~bm) << (64 - bits); | |
res |= (little & ((1L << (64 - bits)) - 1)) << ls; | |
res |= big & bm; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testTcp() throws InterruptedException { | |
new Thread(new Runnable() { | |
@Override | |
public void run() { | |
try { | |
ServerSocket ss = new ServerSocket(); | |
ss.bind(new InetSocketAddress(2121)); | |
Socket client = ss.accept(); | |
byte[] data = new byte[200]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BeanPropertySqlParameterSourceNotThreadSafeTest { | |
@Test | |
public void test() throws InterruptedException { | |
BeanPropertySqlParameterSource sps = new BeanPropertySqlParameterSource(new ImmutableClass()); | |
Thread[] threads = new Thread[1000]; | |
CountDownLatch latch = new CountDownLatch(1000); | |
for (int i = 0; i < 1000; i++) { | |
Thread th = new TestThread(latch, sps); | |
threads[i] = th; | |
th.start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* {@link ExecutorService} wrapper, limit max parallel threads to provided limit. | |
* May be useful for task with different parrallelism over the same executor. | |
* | |
* @author alexkasko | |
* Date: 7/6/12 | |
*/ | |
public class LimitedExecutorServiceWrapper implements ExecutorService { | |
private final ExecutorService target; | |
private final Semaphore semaphore; |
NewerOlder