This file contains 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 test.another; | |
import java.util.concurrent.CountDownLatch; | |
public class TestThread extends Thread{ | |
public static void main(String[] args) { | |
CountDownLatch latch = new CountDownLatch(2); | |
new Thread(new TestRunnable(latch, "1")).start(); | |
new Thread(new TestRunnable(latch, "2")).start(); |
This file contains 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 test.another; | |
import java.util.concurrent.TimeUnit; | |
public class TestThreadJoin { | |
public static void main(String[] args) throws InterruptedException { | |
Thread t1 = new JoinedThread("1"); | |
t1.start(); | |
// Thread 2 waits for thread 1 to end |
This file contains 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
/* | |
* Demonstrate thread.interrupt() method; | |
*/ | |
package test.another; | |
import java.util.concurrent.TimeUnit; | |
public class TestInterrupt { | |
public static void main(String[] args) { | |
Thread t1,t2; |
This file contains 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
/* | |
* Semaphore example | |
*/ | |
package test.another; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Random; | |
import java.util.concurrent.ExecutorService; |
This file contains 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
/* | |
* Basic usage of Java annotation | |
*/ | |
package test.another; | |
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; |
This file contains 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
@RequestMapping(value="/pushMsg") | |
public void pushMsg(HttpServletRequest request, HttpServletResponse response){ | |
long t0 = System.currentTimeMillis(); | |
log.info("Starting "); | |
Continuation continuation = ContinuationSupport.getContinuation(request); | |
continuation.setTimeout(5000); | |
continuation.suspend(); | |
long t1 = System.currentTimeMillis(); | |
log.info("Suspended "); | |
Integer count=(Integer) continuation.getAttribute("count"); |
This file contains 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
\documentclass[12pt,oneside,a4]{article} | |
\usepackage{forloop} | |
\usepackage{ifthen} | |
\usepackage{graphicx} | |
\usepackage{pdfpages} | |
\setlength{\parindent}{0pt} |
This file contains 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
(use 'com.rpl.specter) | |
;; 过滤元素 | |
(filter odd? [1 2 3 4 5 6]) ;; (1 3 5) | |
(select [ALL odd?] [1 2 3 4 5 6]) ;; [1 3 5] | |
;; 选择奇数位的元素 | |
(select [INDEXED-VALS (comp odd? first) LAST] [:a :b :c :d :e]) ;; [:b :d] | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
This file contains 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
(defn invoke-get [obj ^String field] | |
(.. obj | |
(getClass) | |
(getDeclaredMethod (str "get" (clojure.string/capitalize field)) (into-array Class nil)) | |
(invoke obj (into-array Class nil)))) | |
(invoke-get (java.util.Date.) "time") |
OlderNewer