java:java
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| java:java [2022/07/26 06:58] – [org.hibernate.connection.C3P0ConnectionProvider with c3p0 connection pool] admin | java: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, | ThreadLocalRandom.current().nextInt(min, | ||
| + | </ | ||
| + | ==== Md5 ==== | ||
| + | <code java> | ||
| + | import java.util.HashMap; | ||
| + | import java.security.MessageDigest; | ||
| + | public static String md5(String original) { | ||
| + | try{ | ||
| + | MessageDigest md = MessageDigest.getInstance(" | ||
| + | md.update(original.getBytes()); | ||
| + | byte[] digest = md.digest(); | ||
| + | StringBuffer sb = new StringBuffer(); | ||
| + | for (byte b : digest) { | ||
| + | sb.append(String.format(" | ||
| + | } | ||
| + | return sb.toString(); | ||
| + | }catch(Exception e){ | ||
| + | return ""; | ||
| + | } | ||
| + | } | ||
| </ | </ | ||
| ==== Java Reflection ==== | ==== Java Reflection ==== | ||
| Line 562: | Line 581: | ||
| * **Atomic variables** have features that minimize synchronization and help avoid memory consistency errors. | * **Atomic variables** have features that minimize synchronization and help avoid memory consistency errors. | ||
| * **ThreadLocalRandom** (in JDK 7) provides **efficient generation of pseudorandom numbers from multiple threads**. | * **ThreadLocalRandom** (in JDK 7) provides **efficient generation of pseudorandom numbers from multiple threads**. | ||
| - | === Executor Interfaces === | + | |
| - | === Thread pools === | + | ==== Thread pools ==== |
| + | {{: | ||
| refer: | refer: | ||
| - | * https://docs.oracle.com/javase/ | + | * https://www.baeldung.com/thread-pool-java-and-guava |
| - | * http:// | + | |
| * http:// | * http:// | ||
| + | * http:// | ||
| 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 | ||
| Line 1252: | Line 1272: | ||
| * {{: | * {{: | ||
| - | ==== Hibernate connection pooling | + | ==== Default |
| - | Below are basic steps config for connections in Hibernate(each connection in MySQL was a session in Hibernate): | + | Below are basic steps config for connections in Hibernate(each connection in MySQL was a session in Hibernate)(refer: https:// |
| - Config max connections in MySQL: | - Config max connections in MySQL: | ||
| * config temporary in MySQL Admin console:< | * config temporary in MySQL Admin console:< | ||
| Line 1285: | Line 1305: | ||
| } | } | ||
| </ | </ | ||
| - | ==== c3p0 connection pool==== | ||
| Most important Hibernate JDBC properties:< | Most important Hibernate JDBC properties:< | ||
| < | < | ||
java/java.1658818707.txt.gz · Last modified: (external edit)
