8 Carl_Hugo

尚未进行身份认证

Knowledge is Power

等级
TA的排名 8k+

线程池

JAVA线程池的实现使用线程池的好处降低资源消耗提高响应速度提高线程的可管理性Executor框架作用:线程工厂,可以通过Executors创建特定功能的线程池。线程池的种类1. newFixedThreadPool(num)固定数量的线程池,线程池中只存在核心线程,线程池中的核心线程数等于最大线程数,当有新的任务来临时不会开辟新的线程来处理任务...

2018-07-16 22:12:37

ClassLoader简介

**作用:**ClassLoader是用来动态加载class文件到内存中。JAVA默认提供三个classLoaderBootStrap ClassLoader:启动类加载器,负责加载JDK中的核心类库。Extension ClassLoader:扩展类加载器,负责加载JAVA的扩展类库。App ClassLoader: 系统类加载器, 加载应用程序classpath目录下的所有j...

2018-07-03 22:44:59

垃圾收集器(垃圾收集算法的实现)

Serial收集器单线程垃圾收集器,在其进行垃圾收集的时候需要暂停其他的线程。 Serial收集器是Client模式下的默认新生代垃圾收集器。 ParNew收集器Serial收集器的多线程版本,是Server模式下默认新生代垃圾收集器。 Parallel Scavenge收集器新生代垃圾收集器 ,使用的算法是复制算法,也是并行多线程收集器。和ParNew的区别是,Pa...

2018-07-03 21:44:59

垃圾回收算法(内存回收的方法论)

1.引用计数法对对象设置一个引用计数器,每增加一个变量对它的引用计数器就加1。每减少一个引用,计数器就减1。当对象的引用计数器变为0时,该对象才会被回收。 缺陷:1.频繁的对引用进行加减操作会增加系统的消耗2.会产生循环引用导致内存泄漏。2.标记清除法将垃圾回收分成两个阶段:标记阶段和清除阶段。通过标记从根节点开始可达的对象,未被标记的就是未被引用的垃圾对象。清除阶段是清除未被标记的...

2018-07-03 21:28:07

Jpa中ManyToMany和OneToMany的双向控制

Jpa中ManyToMany和OneToMany的双向控制下面我们使用权限管理中Role<->Account(用户ManyToMany账号)、Role<->Domain(用户OneToMany权限域)的关系来举例。    1、ManyToMany Account表 在两个表的对应属性上添加JoinColumns和inverseJoinColumns...

2018-06-05 20:39:28

167. Two Sum II - Input array is sorted

Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of t...

2018-04-10 10:35:22

137. Single Number II

Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your algorithm should have a linear runtime com...

2018-04-10 10:23:25

136. Single Number

Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it wi...

2018-04-10 09:12:21

shell脚本定时重启tomcat

crond 是linux用来定期执行程序的命令,我们通过crond来定期执行shell脚本重启tomcat。下面我以CentOS release 6.3(版本查看cat /etc/issue)为例详细描述一下操作步骤:1、编写shell脚本 vi restart_cat.sh#!/bin/sh . /etc/profile pid=`ps aux | grep tom...

2018-04-08 10:11:07

400. Nth digit

在无限的整数序列 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, …中找到第 n 个数字。 注意: n 是正数且在32为整形范围内 ( n < 231)。 示例 1: 输入: 3 输出: 3 示例 2: 输入: 11 输出: 0 说明: 第11个数字在序列 1,...

2018-04-02 09:18:23

53 Maximum Subarray

给定一个序列(至少含有 1 个数),从该序列中寻找一个连续的子序列,使得子序列的和最大。 例如,给定序列 [-2,1,-3,4,-1,2,1,-5,4], 连续子序列 [4,-1,2,1] 的和最大,为 6。 扩展练习: 若你已实现复杂度为 O(n) 的解法,尝试使用更为精妙的分治法求解。解题思路: 边界: dp[0] = nums[0]...

2018-04-01 20:56:13

103. 二叉树的锯齿形层次遍历

计算给定二叉树的所有左叶子之和。 示例: 在这个二叉树中,有两个左叶子,分别是 9 和 15,所以返回 24 3 / \ 9 20 / \ 15 7解题思路: 层序遍历,当一个节点的左节点存在,并且该左节点为叶子节点,则将它的值累加。/** * Definition for a binary tree n...

2018-03-26 17:21:21

155. Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top

2018-03-24 18:19:00

21. Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example: Input: 1->2->4, 1->3-...

2018-03-21 16:14:42

142. Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. Follow up: Can you solve it without using ext...

2018-03-21 15:50:13

75. Sort Colors

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use ...

2018-03-21 15:09:10

8. String to Integer (atoi)

Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the poss...

2018-03-21 14:33:30

70. Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n wi...

2018-03-20 15:42:43

225. Implement Stack using Queues

Implement the following operations of a stack using queues. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the top element. ...

2018-03-20 15:25:54

232. Implement Queue using Stacks

Implement the following operations of a queue using stacks. push(x) – Push element x to the back of queue. pop() – Removes the element from in front of queue. peek() – Get the fr...

2018-03-20 15:08:57

查看更多

勋章 我的勋章
  • 持之以恒
    持之以恒
    授予每个自然月内发布4篇或4篇以上原创或翻译IT博文的用户。不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!