User Tools

Site Tools


java:java

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
java:java [2022/07/26 07:22] – [Executor Interfaces] adminjava:java [2024/05/31 05:22] (current) – [Random in Java] admin
Line 401: Line 401:
 // so add 1 to make it inclusive // so add 1 to make it inclusive
 ThreadLocalRandom.current().nextInt(min, max + 1); ThreadLocalRandom.current().nextInt(min, max + 1);
 +</code>
 +==== Md5 ====
 +<code java>
 +import java.util.HashMap;
 +import java.security.MessageDigest;
 +public static String md5(String original) {
 +    try{
 +        MessageDigest md = MessageDigest.getInstance("MD5");
 +        md.update(original.getBytes());
 +        byte[] digest = md.digest();
 +        StringBuffer sb = new StringBuffer();
 +        for (byte b : digest) {
 +            sb.append(String.format("%02x", b & 0xff));
 +        }
 +        return sb.toString();
 +    }catch(Exception e){
 +        return "";
 +    }
 +}
 </code> </code>
 ==== Java Reflection ==== ==== Java Reflection ====
Line 566: Line 585:
 {{:java:thread-pool-tasks.png|}} {{:java:thread-pool-tasks.png|}}
 refer:  refer: 
-  * https://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html 
-  * http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html 
   * https://www.baeldung.com/thread-pool-java-and-guava   * https://www.baeldung.com/thread-pool-java-and-guava
   * http://howtodoinjava.com/2012/10/20/how-to-use-blockingqueue-and-threadpoolexecutor-in-java   * http://howtodoinjava.com/2012/10/20/how-to-use-blockingqueue-and-threadpoolexecutor-in-java
 +  * http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html
 Thread pools address two different problems:  Thread pools address two different problems: 
   * They usually provide improved performance when **executing large numbers of asynchronous tasks**, due to reduced per-task invocation overhead   * They usually provide improved performance when **executing large numbers of asynchronous tasks**, due to reduced per-task invocation overhead
java/java.1658820126.txt.gz · Last modified: 2022/10/29 16:15 (external edit)