`
yaojingguo
  • 浏览: 208146 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论
文章列表
class A { } class B extends A { } public class Usage { public static void main(String[] args) { A[] aArr1 = new A[1]; A[] aArr2 = new B[1]; aArr1[0] = new B(); B[] bArr1 = (B[]) aArr2; B[] bArr3 = new B[1]; aArr1 = bArr3; B[] bArr2 = (B[]) aArr1; } } ...
The following code print null. If using InheritableThreadLocal, it print main.     class A { //static ThreadLocal local = new InheritableThreadLocal(); static ThreadLocal local = new ThreadLocal(); } public class Sample { public static void main (String [] args) { A.local.set(&qu ...
When doing development work with Java project whose's classpath is complex, I need to make sure which classpath is appended to CLASSPATH before others. Here is the rule: 1. output folder is appended first. 2. Other classpathentries are appended as the order that they are listed in .classpath. The o ...
I can't login to http://bugs.sun.com/ these days. So I write it here for reference. In line 39 of ThreadLocal.java (http://download.oracle.com/javase/6/docs/api/java/lang/ThreadLocal.html), uniqueId should be uniqueNum. The following code shows the reason.    import java.util.concurrent.atomic.Atom ...
Runnable version of sample code in Exchanger's javadoc.   import java.util.concurrent.Exchanger; public class FillAndEmpty { static String PART = "abcde"; static int PART_LEN = 5; static int STEP_COUNT = 10; Exchanger<StringBuilder> exchanger = new Exchanger< ...
Runnable version of Solver sample code in CyclicBarrier's javadoc.   import java.util.concurrent.*; public class Solver { final int N; final float[][] data; final CyclicBarrier barrier; class Worker implements Runnable { int myRow; Worker(int row) { myRow = row; } ...
import java.util.concurrent.atomic.*; class Container { public volatile int no; } class Task extends Thread { private AtomicIntegerFieldUpdater<Container> updater = AtomicIntegerFieldUpdater.newUpdater(Container.class, "no"); private Container c; public Ta ...

timer in libevent

#include <event.h> #include <stdio.h> #include <time.h> static void hello(int fd, short event, void *arg) { printf("hello man\n"); } int main(int argc, const char *argv[]) { struct event_base *base; struct timeval tm; struct event evt; ...
This is little script shows the usage of $#, $* and $@ in bash.   #!/bin/bash function countargs { echo "$# args." } echo "$*" countargs "$*" countargs "$@"  
  #include <stdio.h> #include <stdlib.h> /* * str is a literal. So it is allocated in readonly segment. It is OK to return * it. But the data pointed by the pointer can't be modified. */ char *static_pointer_return() { char *str = "world"; return str; } ...
http://stackoverflow.com/questions/3332917/hadoop-job-fails-when-invoked-by-cron
Sample code showing some tricks of C macro usage.       #include <stdio.h> /* * Argument concatenation */ #define concatenate(front, back) front ## back /* * GNU C extension. Refer to * http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#SEC76 */ #define gnu_eprintf(for ...
Make the tail queue sample in man page work.   #include <sys/queue.h> #include <stdlib.h> #include <stdio.h> int main(int argc, const char *argv[]) { TAILQ_HEAD(tailhead, entry) head; struct tailhead *headp; headp = &head; struct entry { ...
http://www.network-theory.co.uk/docs/gccintro/gccintro_21.html   And library specified by LD_LIBRARY_PATH take precedence over system library directories.
There is no documentation download on http://monkey.org/~provos/libevent/ and its sourceforge project web site. To generate libevent documentation by yourself, follow the following steps.   git clone git://levent.git.sourceforge.net/gitroot/levent/levent ./autogen.sh ./configure ./make doxyge ...
Global site tag (gtag.js) - Google Analytics