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
| interface Computable<A, V> { | |
| V compute(A a); | |
| } | |
| public class Memorizer<A, V> implements Computable<A, V> { | |
| private final ConcurrentMap<A, Future<V>> cache = new ConcurrentHashMap<>(); | |
| private final Computable<A, V> computable; | |
| public Memorizer(Computable<A, V> computable) { | |
| this.computable = computable; |
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
| /** | |
| * Description: Concurrent Stack | |
| * | |
| * @author liuzhengyang | |
| * @version 1.0 | |
| * @since 2016-04-07 | |
| */ | |
| public class ConcurrentStack<E> { | |
| private AtomicReference<Node<E>> top = new AtomicReference<>(); |
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
| package com.lzy.algo.collect; | |
| import java.util.concurrent.atomic.AtomicReference; | |
| /** | |
| * Description: Concurrent Stack | |
| * | |
| * @author liuzhengyang | |
| * @version 1.0 | |
| * @since 2016-04-07 |
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
| Object[] objects = new String[]{"s"}; | |
| objects[0] = 2; | |
| System.out.println("h"); |
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
| private final class Sync extends AbstractQueuedSynchronizer { | |
| private int count; | |
| public Sync(int count) { | |
| this.count = count; | |
| } | |
| @Override | |
| protected int tryAcquireShared(int arg) { | |
| return (getState() == 0 ? 1 : -1); |
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 UDPServer { | |
| public void start() { | |
| try { | |
| DatagramChannel datagramChannel = DatagramChannel.open(); | |
| datagramChannel.bind(new InetSocketAddress(8089)); | |
| while(true) { | |
| ByteBuffer byteBuffer = ByteBuffer.allocate(1024); | |
| SocketAddress receive = datagramChannel.receive(byteBuffer); | |
| byteBuffer.flip(); | |
| System.out.println("Receive " + byteBuffer.toString()); |
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
| package com.github.lzy.web.net.udp; | |
| import java.io.IOException; | |
| import java.net.DatagramPacket; | |
| import java.net.DatagramSocket; | |
| import java.net.InetSocketAddress; | |
| import java.net.SocketAddress; | |
| import java.net.SocketException; | |
| import java.nio.ByteBuffer; | |
| import java.nio.channels.DatagramChannel; |
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
| package com.github.lzy.web.net; | |
| import java.io.IOException; | |
| import java.net.DatagramPacket; | |
| import java.net.DatagramSocket; | |
| import java.net.InetSocketAddress; | |
| import java.net.SocketException; | |
| /** | |
| * Description: |
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
| /* | |
| * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * | |
| * |
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
| import java.lang.reflect.*; | |
| import java.lang.reflect.Method; | |
| import java.util.*; | |
| import sun.jvm.hotspot.memory.*; | |
| import sun.jvm.hotspot.oops.*; | |
| import sun.jvm.hotspot.debugger.*; | |
| import sun.jvm.hotspot.runtime.*; | |
| import sun.jvm.hotspot.tools.*; | |
| import sun.jvm.hotspot.utilities.*; |
OlderNewer