
Java
文章平均质量分 66
嘎嘎986
旅行,是心灵的阅读;而阅读,是心灵的旅行...
展开
-
Difference between Stack and Heap in Java
Here are few differences between stack and heap memory in Java:1) Main difference between heap and stack is that stack memory is used to store local variables and function call, while heap转载 2014-12-02 16:06:04 · 524 阅读 · 0 评论 -
SMTP:防止追踪发件人IP
SMTP-防止追踪发件人IP原创 2015-08-25 17:39:05 · 3520 阅读 · 0 评论 -
使用spring-data-redis操作Redis的Sentinel
环境: Redis 3.0+jedis 2.4.1 启动3个redis实例,1个master,2个slave./src/redis-server redis sentinel原创 2015-08-25 15:22:13 · 751 阅读 · 0 评论 -
Effective Java 78条军规
Effective Java, 2nd Editionby Joshua BlochI, Michael Parker, own this book and took these notes to further my own learning. If you enjoy these notes, please purchase the book!Chapter原创 2015-08-27 12:18:24 · 1837 阅读 · 0 评论 -
Keytool证书管理
《JAVA加密与解密的艺术》梁栋著 1:这里我们使用”www.zlex.org” 作为别名,使用RSA作为加密算法,并规定密钥长度为2048位,使用SHA1withRSA作为数字签名算法,欲签发有效期为36000天的数字证书。 keytool -genkeypair -keyalg RSA -keysize 2048 -sigalg SHA1withRSA -validity 36000 -al转载 2015-08-07 13:33:19 · 485 阅读 · 0 评论 -
Java加密与解密的艺术-对称加密算法
解密算法是加密算法的逆运算,加密密钥和解密密钥相同。如果我们把Base64算法改良,将其字符映射表作为密钥保存,就可以把这个改良后的Base64算法作为一种对称加密算法来看。DESede算法(又称为TrippleDES或3DES算法)翻译成中文就是三重DES算法。 DES算法具有代表性,堪称典范;DESede是DES算法的变种,AES算法则作为DES算法的替代者;而IDEA算法作为一种强加密算法,原创 2015-08-27 16:39:34 · 666 阅读 · 0 评论 -
Java加密与解密的艺术-非对称加密
场景:银行工作人员验明户主身份后,拿出另一把钥匙同户主一起打开保险柜,这个保险柜称为’双钥保险柜’。相比于对称加密算法的单钥体系,非对称加密的双钥体系更为安全。在某些极端情况下,费对称加密算法甚至比对称加密算法慢1000倍。公钥加密的数据,只可用私钥对其解密;私钥加密的数据,只可用公钥对其解密。使用对称加密算法为数据加密/解密,使用公钥和私钥为( 对称加密算法密钥 ) 加密/解密。 RSA算法要求原创 2015-08-27 16:59:32 · 696 阅读 · 0 评论 -
Java加密与解密的艺术-消息摘要算法
消息摘要算法包含MD、SHA、MAC共3大系列,常用于验证数据的完整性,是数字签名算法的核心算法。equals方法比较的是两个对象的散列值,即比较两个对象的hashCode()方法的值是否相同,这说明hashCode可以作为辨别对象的唯一标示。为了方便人们识别和阅读,数字指纹常以十六进制字符串的形式出现。这也是为什么当山东大学王小云教授使用碰撞算法破解了MD5和SHA算法后,使得数字签名在理论上被伪原创 2015-08-27 15:29:12 · 727 阅读 · 0 评论 -
Java加密与解密的艺术-Base64
Base64是一种基于64个字符的编码算法,经过Base64编码后的数据会比原始数据略长,为原来的4/3倍。Bouncy Castle与Commons Codec有差别:Bouncy Castle使用”.”作为补位符,而Commons Codec则完全杜绝使用补位符。尽管如此,Base64仍不能被称为加密算法。Base64算法公开,这一点与柯克霍夫原则并无违背,但充当密钥的字符映射表公开,直接违反了原创 2015-08-27 14:56:04 · 518 阅读 · 0 评论 -
Java Concurrency in Practice 思维导图
JCIP Fundamentals 1-Introduction threads are the easiest way to tap the computing power of multiprocessor systems 1.1-a brief history of concurrency原创 2016-02-25 10:28:02 · 1060 阅读 · 1 评论 -
JCIP思维导图-1-Introduction
1-Introduction start threads are the easiest way to tap the computing power of multiprocessor systems Writing correct concurrent programs is very hard. 1.1-a brief history o原创 2016-02-25 10:31:36 · 705 阅读 · 0 评论 -
JCIP-2-Thread Safety
2-Thread Safety 2.1-What is thread safety start Writing thread-safe code is at its core,about managing access to state,and in particular to shared,mutable state原创 2016-02-25 10:34:31 · 518 阅读 · 0 评论 -
JCIP-3-Sharing Objects
3-Sharing Objects 3.1-Visibility Synchronization also has another significant, and subtle, aspect: memory visibility. You can ensure that objects are published safely either by u原创 2016-02-25 10:38:03 · 465 阅读 · 0 评论 -
JCIP-4-Composing Objects
4-Composing Objects 4.1-Designing a Thread-safe Class 4.1.1. Gathering Synchronization Requirements The design process for a threadͲsafe class should include these three basi原创 2016-02-25 10:41:34 · 566 阅读 · 0 评论 -
JCIP-5-Building Blocks
5-Building Blocks 5.1. Synchronized Collections 5.1.1. Problems with Synchronized Collections 5.1.2. Iterators and Concurrentmodificationexception fail-fast meaning原创 2016-02-25 10:44:48 · 358 阅读 · 0 评论 -
JCIP-6-Task Execution
6-Task Execution 6.1-Executing tasks in threads 6.1.1. Executing Tasks Sequentially 6.1.2. Explicitly Creating Threads for Tasks 6.1.3. Disadvantages of Unbounded Thread原创 2016-02-25 10:46:44 · 508 阅读 · 0 评论 -
JCIP-7-Cancelletion and Shutdown
7-Cancelletion and Shutdown 7.1-Task cancellation 7.1.1. Interruption Java does not provide any mechanism for safely forcing a thread to stop what it is doing.[1] Instead, i原创 2016-02-25 10:48:12 · 492 阅读 · 0 评论 -
Netty官方指南: User guide for 4.x
http://netty.io/wiki/user-guide-for-4.x.html 目前关于netty的书籍仅有一本<>是netty团队成员写的,但新版的出版日期一再拖后(7月31又推到了8月31),无法订购。 国内的Netty权威指南 感觉编辑不是太好了,大量截图和不必要的打印结果很让人恼火。两本书除了将NIO和OIO区别讲下,大部分内容也就是官方指南的细化。翻译 2015-08-07 17:10:25 · 767 阅读 · 0 评论 -
Email Best Practices邮件发送策略最佳实践
Email Best PracticesReputationHostingIP Addresses and Sending VolumeDNSAuthenticationMailing ListsBounce and ESP Feedback HandlingFeedback Loops and Spam ComplaintsUnsubscribe HandlingRecipient翻译 2015-03-27 13:46:59 · 3681 阅读 · 1 评论 -
java.util.concurrent
What is thread-safety?A class is thread-safe if it behaves correctly when accessed from multiple threads, regardless of the scheduling orinterleaving of the execution of those threads by the runti翻译 2015-03-27 20:56:18 · 501 阅读 · 0 评论 -
for-each循环应优先于传统的for循环
嵌套迭代使用Iterator可能导致的unintended failure原创 2015-05-14 11:57:12 · 564 阅读 · 0 评论 -
Chapter 2. Thread Safety
informally, an object's state is its data, stored in state variables such as instance or static fields. CopyIf multiple threads access the same mutable state variable without appropria翻译 2014-12-02 16:17:38 · 448 阅读 · 0 评论 -
runtime动态定义的JavaBean:DynaBean,DynaClass,DynaProperty
A DynaBean is a Java object that supports properties whose names and data types, as well as values, may be dynamically modified. To the maximum degree feasible, other components of the BeanUtils pac原创 2014-12-04 15:18:00 · 872 阅读 · 0 评论 -
Java Concurrency in Practice读书笔记
java concurrency in practice.pdf2014-12-04 23:19:11Effectively immutable objects must be safely published; Mutable objects must be safely published, and must be either threadsafe or guarded by a原创 2014-12-06 21:20:31 · 955 阅读 · 0 评论 -
With a Java ExecutorService, how do I complete actively executing tasks but halt the processing of w
如何让正在执行的任务执行完,等待执行的任务全部取消?I want something in between these two options.I want to call a command that: a. Completes the currently active task or tasks (like shutdown). b. Halts the pro翻译 2015-03-27 15:15:30 · 367 阅读 · 0 评论 -
Under what conditions will BlockingQueue.take throw interrupted exception?
Poison Pill:A good way to signal termination of a blocking queue is to submit a 'poison' value into the queue that indicates a shutdown has occurred. This ensures that the expected behavior of the q原创 2015-03-27 13:52:36 · 529 阅读 · 0 评论 -
iptables防火墙添加规则
1:放开mysql 3306端口方法:iptables -I INPUT 1 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT2:未添加过规则的iptables文件在/etc/sysconfig 目录下找不到The /etc/sysconfig/iptables-config file store原创 2015-03-27 13:55:32 · 605 阅读 · 0 评论 -
SMTP:防止追踪发件人IP
1:使用网页版gmail发信,邮件头不带X-Originating-IP2:javamail调用SMTP时加代理: props.put( "mail.smtp.socks.host","10.11.220.2" ); props.put( "mail.smtp.socks.port", Integer.toString(1原创 2015-03-27 13:49:54 · 3479 阅读 · 0 评论 -
java.util.concurrent.locks.Lock
java.util.concurrent.locks.LockLock implementations provide more extensive locking operations than can be obtained using synchronized methods and statements. They allow more flexible structuri翻译 2015-03-27 20:11:48 · 451 阅读 · 0 评论 -
优先选择基本类型而不是基本类型的包装类型
Effective Java翻译 2015-05-11 11:54:51 · 582 阅读 · 0 评论 -
java.sql.Timestamp的equals违反了对称性
JDK 文档说明:Note: This type is a composite of a java.util.Date and a separate nanoseconds value. Only integral seconds are stored in the java.util.Date component. The fractional seconds - the nan原创 2015-05-13 11:08:56 · 688 阅读 · 0 评论 -
当心字符串连接符影响性能
Effective Java读书笔记原创 2015-05-14 11:21:23 · 446 阅读 · 0 评论 -
ExecutorCompletionService
ExecutorCompletionService原创 2015-05-14 17:06:28 · 418 阅读 · 0 评论 -
Java加密与解密的艺术-读书笔记1-2章
作者-梁栋第1章:企业应用安全不管是哪一种IM工具,都在不遗余力地告诫用户聊天信息可能被盗取。大批量、高负荷的数据交互时如何确定对方就是你所依赖的合作伙伴呢?并不能保证手机平台就能比PC平台有着更高的安全性!企业内部能访问数据库的员工能轻而易举地盗取用户的用户名和口令。“计算机安全”的定义为:为数据处理系统建立和采取的技术和管理的安全保护,保护计算机硬件、软件数据不因偶然和原创 2015-08-08 16:48:08 · 630 阅读 · 0 评论 -
Netty官方指南: User guide for 4.x
http://netty.io/wiki/user-guide-for-4.x.html目前关于netty的书籍仅有一本>是netty团队成员写的,但新版的出版日期一再拖后(7月31又推到了8月31),无法订购。国内的Netty权威指南 感觉编辑不是太好了,大量截图和不必要的打印结果很让人恼火。两本书除了将NIO和OIO区别讲下,大部分内容也就是官方指南的细化。相对而言,Netty in原创 2015-08-08 16:51:15 · 1508 阅读 · 0 评论 -
Java加密与解密的艺术-读书笔记3-4章
第3章-Java加密利器Java安全领域组成部分:Java安全领域总共分为4个部分:JCA(Java Cryptography Architecture,Java加密体系结构)、JCE(Java Cryptography Extension Java加密扩展包)、JSSE(Java Secure Sockets Extensions Java安全套接字扩展包)、JAAS(Java Authen原创 2015-08-08 18:13:15 · 746 阅读 · 0 评论 -
Compilation error in Node.getTextContent for jdk 6
getTextContent() not found in the jdk 6原创 2015-08-25 15:12:22 · 641 阅读 · 0 评论 -
做精确计算时应避免使用float和double
The float and double types are particularly illsuited for monetary calculations.原创 2015-05-15 14:16:36 · 517 阅读 · 0 评论 -
JCIP-8-Applying Thread Pools
8-Applying Thread Pools 8.1. Implicit Couplings Between Tasks and Execution Policies start ThreadLocal makes sense to use in pool threads only if the thread-local value has原创 2016-02-25 10:49:39 · 572 阅读 · 0 评论