<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[toseektruth的博客]]></title><description><![CDATA[]]></description><link>https://blog.youkuaiyun.com/toseektruth</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; toseektruth]]></copyright><item><title><![CDATA[Socket编程]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/77799898</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/77799898</guid><author>toseektruth</author><pubDate>Sat, 02 Sep 2017 11:07:34 +0800</pubDate><description><![CDATA[本文主要内容参考自此处，如有兴趣可自行查看（英文版），这里是本人对于该部分内容的理解和总结。1. 关于Socket通信Q1: socket是什么，该怎么理解？ 
A1:这里引用JLS定义
  java.net.Socket
  
  This class implements client sockets (also called just “sockets”). A socket is an en]]></description><category></category></item><item><title><![CDATA[实现最小栈]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/77686148</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/77686148</guid><author>toseektruth</author><pubDate>Tue, 29 Aug 2017 20:02:30 +0800</pubDate><description><![CDATA[1. 要求 及思路
  实现一个最小栈，主要实现包括以下方法，且满足操作的时间复杂度为O(1)： 
  void push(E val): 压入一个元素； 
  E pop()：从栈中弹出一个元素； 
  E top()：返回栈顶元素； 
  E min()：返回栈中最小元素；
思路：这里考虑用2个栈实现，用内存换取效率。
  其中一个栈用来存当前容器中的最小值；另一个栈用来存所有元素。
2. Ja]]></description><category></category></item><item><title><![CDATA[工厂设计模式]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/77670717</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/77670717</guid><author>toseektruth</author><pubDate>Tue, 29 Aug 2017 10:11:41 +0800</pubDate><description><![CDATA[1. 什么是工厂设计模式？本文部分内容参考自这2个地址，包括这里及这里，如有兴趣可自行前往查看。
  Factory design pattern is used when we have a super class with multiple sub-classes and based on input, we need to return one of the sub-class. This p]]></description><category></category></item><item><title><![CDATA[Multi-Programming-17  Semaphore & CountDownLatch信号量和计数栓之间的关系]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/77622139</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/77622139</guid><author>toseektruth</author><pubDate>Sun, 27 Aug 2017 18:40:11 +0800</pubDate><description><![CDATA[1. 信号量与计数栓Semaphore & CountdownLatch关于该问题的Q&A主要来自此处，可以自行查看。
  信号量：Semaphore is used to control the number of concurrent threads that are using a resource. That resource can be something like a file, or]]></description><category></category></item><item><title><![CDATA[Multi-Programming-16 线程死锁实现方式]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/77620576</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/77620576</guid><author>toseektruth</author><pubDate>Sun, 27 Aug 2017 15:16:58 +0800</pubDate><description><![CDATA[1. 简单实现：使用synchronized方法
  
  Mutual exclusion:互斥访问
  Hold and wait：拥有等待
  Non-emptive：不可剥夺
  Circular waiting：循环等待
  
package com.fqyuan._11deadlock;public class DeadLockOri {
    private static Objec]]></description><category></category></item><item><title><![CDATA[Multi-Programming-15 线程顺序执行]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/77619657</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/77619657</guid><author>toseektruth</author><pubDate>Sun, 27 Aug 2017 12:19:34 +0800</pubDate><description><![CDATA[1. 问题
  Q：假设有三个线程，假设为t1, t2, t3， 如何保证线程的顺序执行t1->t2->t3？ 
  A：首先，java语言多线程机制并没有执行顺序的属性；其次，设置线程的优先级并不能确保线程的准确执行顺序。所以，这里需要采用其他方式保证执行了。 
  本文提供了三种解决方式： 
  1). ReentrantLock: 重入锁方案。 
  2). Condition: 类似于wai]]></description><category></category></item><item><title><![CDATA[Comparable接口和Comparator接口]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/77503992</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/77503992</guid><author>toseektruth</author><pubDate>Wed, 23 Aug 2017 11:33:34 +0800</pubDate><description><![CDATA[1.  关于2个接口文档说明1). Comparable：  
实现了该接口的类可以直接进行排序，在调用Collections静态方法进行排序时无需指定Comparator, 因为实现了该类的对象本身是可比较的。
  需实现方法：public int compareTo(Object o){} 
  This interface imposes a total ordering on the obj]]></description><category></category></item><item><title><![CDATA[线程安全的单例模式]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/77500432</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/77500432</guid><author>toseektruth</author><pubDate>Wed, 23 Aug 2017 10:05:54 +0800</pubDate><description><![CDATA[1. 单例模式这里有单例模式的wiki定义：
  In software engineering, the singleton pattern is a software design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is]]></description><category></category></item><item><title><![CDATA[数据结构--队列实现栈&栈实现队列]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/77450639</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/77450639</guid><author>toseektruth</author><pubDate>Mon, 21 Aug 2017 15:45:36 +0800</pubDate><description><![CDATA[1. 两个栈实现栈
  1.这里使用的是ArrayDequeue, 而不是使用Stack，因为Stack 集合是在Java Collection Framework被淘汰的集合。 
  2. 这里push操作增加的元素放在stack1中； 
  3. 这里pop操作作用集合为stack2, 如果stack2为空，则将stack1中元素push到stack2中，然后再stack2进行pop()操作。]]></description><category></category></item><item><title><![CDATA[10种排序算法总结]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/77315902</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/77315902</guid><author>toseektruth</author><pubDate>Thu, 17 Aug 2017 10:54:20 +0800</pubDate><description><![CDATA[这里把常见的排序算法做个总结，包括 
  1). SelectSort–选择排序 
  2). InsertSort–插入排序 
  3). BubbleSort–冒泡排序 
  4). ShellSort–希尔排序 
  5). MergeSort–归并排序 
  6). QuickSort–快速排序 
  7). HeapSort–堆排序 
  8). CountSort–计数排序 
  9).]]></description><category></category></item><item><title><![CDATA[Algorithm-Arrays-8 Noble Integer]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/77141284</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/77141284</guid><author>toseektruth</author><pubDate>Sun, 13 Aug 2017 11:48:49 +0800</pubDate><description><![CDATA[1.  题目描述
  Given an integer array, find if an integer p exists in the array such that the number of integers greater than p in the array equals to p 
  If such an integer is found return 1 else return]]></description><category></category></item><item><title><![CDATA[Algorithm-Arrays-7 Diagonals 对角线输出]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/77141093</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/77141093</guid><author>toseektruth</author><pubDate>Sun, 13 Aug 2017 11:17:07 +0800</pubDate><description><![CDATA[1.  题目
  Give a N*N square matrix, return an array of its anti-diagonals. Look at the example for more details.
  
  Example:
  
  Input:     
  
  1 2 3 
  4 5 6 
  7 8 9
  
  Return the following :]]></description><category></category></item><item><title><![CDATA[Algorithm-Arrays-6 Kth pascal triangle]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/77140081</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/77140081</guid><author>toseektruth</author><pubDate>Sun, 13 Aug 2017 09:50:40 +0800</pubDate><description><![CDATA[1. 题目: Kth Row of Pascal’s Triangle此处有关于该问题的类似解法。
  Given an index k, return the kth row of the Pascal’s triangle.
  
  Pascal’s triangle : To generate A[C] in row R, sum up A’[C] and A’[C-1] from prev]]></description><category></category></item><item><title><![CDATA[关于Java中HashMap相关总结]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/76460575</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/76460575</guid><author>toseektruth</author><pubDate>Mon, 31 Jul 2017 17:40:13 +0800</pubDate><description><![CDATA[1. 关于该问题的一些导入问题1.Immutable 和 final之间有什么不同？ 
A: 关于该问题在StackOverflow上有相关解答,这里做了总结.//Ok
String name = "John";
name = "Sam";   //Ok.//Error
final String name = "John";
name = "Sam";   //Compile error
  fin]]></description><category></category></item><item><title><![CDATA[封装类为何是immutable 不可改变的]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/76422912</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/76422912</guid><author>toseektruth</author><pubDate>Mon, 31 Jul 2017 11:13:38 +0800</pubDate><description><![CDATA[1. 问题引入demopackage com.fqyuan.Wrapper;import java.util.concurrent.atomic.AtomicInteger;public class TestWrapper {    public static void main(String[] args) {
        Foo f1 = new Foo();
        Foo f2]]></description><category></category></item><item><title><![CDATA[为何String对象是immutable或final的？]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/76420961</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/76420961</guid><author>toseektruth</author><pubDate>Mon, 31 Jul 2017 10:33:19 +0800</pubDate><description><![CDATA[1. 问题引入本文内容主要参考自此处，感兴趣者可以自行移步查看。 
另，StackOverflow上也有关于该问题的回答，这里贴出部分答案。
  String is immutable for several reasons, here is a summary:
  
  
  Security: parameters are typically represented as String in]]></description><category></category></item><item><title><![CDATA[单例模式下的双重检验锁Double Checked Locking]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/76407800</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/76407800</guid><author>toseektruth</author><pubDate>Sun, 30 Jul 2017 21:50:44 +0800</pubDate><description><![CDATA[1.  双重检验锁该部分内容引自维基百科。package com.fqyuan.con_singleton;public class SingletonClass {
    private static volatile SingletonClass INSTANCE;    //private constructor.
    private SingletonClass() {
    }]]></description><category></category></item><item><title><![CDATA[为何Java 类不支持多继承？]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/76396486</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/76396486</guid><author>toseektruth</author><pubDate>Sun, 30 Jul 2017 16:59:02 +0800</pubDate><description><![CDATA[1.问题由来本文部分内容引自此处，感兴趣者可以直接查看原链接。
  Java语言特性之一是, 确切的说，其类对于多继承是不支持的（接口可以多继承），但是这是为什么呢？记得Thinking in Java中对于该问题有所阐述，单继承时，JVM的GC机制很好实现，有没有其他更深层次的原因呢？
2.问题解释     A foo()
       / \
      /   \
  B foo()   C]]></description><category></category></item><item><title><![CDATA[哲学家就餐问题 Java语言实现]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/76377224</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/76377224</guid><author>toseektruth</author><pubDate>Sun, 30 Jul 2017 13:09:01 +0800</pubDate><description><![CDATA[1. 哲学家就餐问题描述本文部分内容来源于此，欲了解详细内容，自行点击查看。   为了不失一般性，我们假设有n个哲学家，围着餐桌思考宇宙、人生问题，每个哲学家面前有一个叉子与之对应，即：共有n个叉子；当哲学家思考一段时间后，他会拿起身边的2个叉子才能进食。进食完毕后，该哲学家放下叉子，继续思考人生、宇宙，如此往复，周而复始。
2. 解决方案
  在解决该类问题时，属于竞争资源情形，假设所有哲学家均同]]></description><category></category></item><item><title><![CDATA[Data Structure-7 HashTable 哈希表]]></title><link>https://blog.youkuaiyun.com/toseektruth/article/details/76302216</link><guid>https://blog.youkuaiyun.com/toseektruth/article/details/76302216</guid><author>toseektruth</author><pubDate>Sat, 29 Jul 2017 12:07:49 +0800</pubDate><description><![CDATA[1. 哈希表部分理论内容参考自这里。
  Hash Table is a data structure which stores data in an associative manner. In a hash table, data is stored in an array format, where each data value has its own unique index value.]]></description><category></category></item></channel></rss>