上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 14 下一页

2013年11月14日

Java的synchronized关键字:同步机制总结

摘要: JAVA中synchronized关键字能够作为函数的修饰符,也可作为函数内的语句,也就是平时说的同步方法和同步语句块。搞清楚synchronized锁定的是哪个对象,就能帮助我们设计更安全的多线程程式。不久前用到了同步,现在回过头来对JAVA中的同步做个总结,以对前段时间工作的总结和自我技术的条理话。JAVA的synchronized关键字能够作为函数的修饰符,也可作为函数内的语句,也就是平时说的同步方法和同步语句块。假如再细的分类,synchronized可作用于instance变量、object reference(对象引用)、static函数和class literals(类名称字面常 阅读全文

posted @ 2013-11-14 12:41 Step-BY-Step 阅读(182) 评论(0) 推荐(0) 编辑

Synchronized Methods

摘要: Synchronized MethodsThe Java programming language provides two basic synchronization idioms:synchronized methodsandsynchronized statements. The more complex of the two, synchronized statements, are described in the next section. This section is about synchronized methods.To make a method synchronize 阅读全文

posted @ 2013-11-14 12:39 Step-BY-Step 阅读(427) 评论(0) 推荐(0) 编辑

java synchronized详解

摘要: 记下来,很重要。Java语言的关键字,当它用来修饰一个方法或者一个代码块的时候,能够保证在同一时刻最多只有一个线程执行该段代码。 一、当两个并发线程访问同一个对象object中的这个synchronized(this)同步代码块时,一个时间内只能有一个线程得到执行。另一个线程必须等待当前线程执行完这个代码块以后才能执行该代码块。 二、然而,当一个线程访问object的一个synchronized(this)同步代码块时,另一个线程仍然可以访问该object中的非synchronized(this)同步代码块。 三、尤其关键的是,当一个线程访问object的一个synchronized(this 阅读全文

posted @ 2013-11-14 12:22 Step-BY-Step 阅读(179) 评论(0) 推荐(0) 编辑

深拷贝与浅拷贝探析

摘要: 转自:http://www.cnblogs.com/phoenix-rock/archive/2006/11/07/shallowcopy_deepcopy.html1.深拷贝是指源对象与拷贝对象互相独立,其中任何一个对象的改动都不会对另外一个对象造成影响。举个例子,一个人名叫张三,后来用他克隆(假设法律允许)了另外一个人,叫李四,不管是张三缺胳膊少腿还是李四缺胳膊少腿都不会影响另外一个人。比较典型的就是Value(值)对象,如预定义类型Int32,Double,以及结构(struct),枚举(Enum)等。考虑以下写法intsource =int.MaxValue;//(1)初始化源对象为整 阅读全文

posted @ 2013-11-14 11:18 Step-BY-Step 阅读(146) 评论(0) 推荐(0) 编辑

StringBuffer 和 StringBuilder

摘要: 如果你读过《Think in Java》,而且对里面描述HashTable和HashMap区别的那部分章节比较熟悉的话,你一定也明白了原因所在。对,就是支持线程同步保证线程安全而导致性能下降的问题。HashTable是线程安全的,很多方法都是synchronized方法,而HashMap不是线程安全的,但其在单线程程序中的性能比HashTable要高。StringBuffer和StringBuilder类的区别也在于此,新引入的StringBuilder类不是线程安全的,但其在单线程中的性能比StringBuffer高。如果我们的程序是在单线程下运行,或者是不必考虑到线程同步问题,我们应该优先 阅读全文

posted @ 2013-11-14 11:09 Step-BY-Step 阅读(243) 评论(0) 推荐(0) 编辑

Java Notes

摘要: 1.java是解释型语言。java虚拟机能实现一次编译多次运行。2.JDK(javasoftwareDevelopmentkit软件开发包),JRE(javaRuntimeEnvironmentjava运行环境)。3.javac编译java程序,java运行java程序。4.一个文件最多有一个publicclass。5.java中switch语句只能探测int类型值(JDK1.6以前)。6.在java中一个字节是八位,一个字符占两个字节(16位unicode字符串)。7.内存中byte占1个字节,int占4个字节,long类型占8个字节;float占4个字节,double占8个字节;boole 阅读全文

posted @ 2013-11-14 11:07 Step-BY-Step 阅读(210) 评论(0) 推荐(0) 编辑

abstract class和interface的区别

摘要: 在Java语言中,abstract class和interface是支持抽象类定义的两种机制。正是由于这两种机制的存在,才赋予了Java强大的面向对象能力。abstract class和interface之间在对于抽象类定义的支持方面具有很大的相似性,甚至可以相互替换,因此很多开发者在进行抽象类定义时对于abstract class和interface的选择显得比较随意。其实,两者之间还是有很大的区别的,对于它们的选择甚至反映出对于问题领域本质的理解、对于设计意图的理解是否正确、合理。Abstract classInterface实例化不能不能类一种继承关系,一个类只能使用一次继承关系。可以通 阅读全文

posted @ 2013-11-14 11:01 Step-BY-Step 阅读(257) 评论(0) 推荐(0) 编辑

Java中super的几种用法并与this的区别

摘要: 1.子类的构造函数如果要引用super的话,必须把super放在函数的首位.classBase {Base() {System.out.println("Base");}}publicclassChecketextendsBase {Checket() {super();//调用父类的构造方法,一定要放在方法的首个语句System.out.println("Checket");}publicstaticvoidmain(String argv[]) {Checketc=newChecket();}}如果想用super继承父类构造的方法,但是没有放在第一行 阅读全文

posted @ 2013-11-14 08:48 Step-BY-Step 阅读(192) 评论(0) 推荐(0) 编辑

Java垃圾收集器

摘要: 概述 说起垃圾收集(Garbage Collection,GC),大部分人都把这项技术当做Java语言的伴生产物。事实上,GC的历史远远比Java久远,1960年诞生于MIT的Lisp是第一门真正使用内存动态分配和垃圾收集技术的语言。当Lisp还在胚胎时期时,人们就在思考: GC需要完成的三件事情: 哪些内存需要回收? 什么时候回收? 如何回收? 经过半个世纪的发展,内存的动态分配与内存回收技术已经相当成熟,一切看起来都进入了“自动化”时代,那为什么我们还要去了解GC和内存分配呢?答案很简单:当需要排查各种内存溢出、内存泄漏问题时,当垃圾收集成为系统达到更高并发量的... 阅读全文

posted @ 2013-11-14 08:16 Step-BY-Step 阅读(297) 评论(0) 推荐(0) 编辑

LRU Cache

摘要: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.set(key, value)- Set or insert the value if the key is not 阅读全文

posted @ 2013-11-14 08:05 Step-BY-Step 阅读(214) 评论(0) 推荐(0) 编辑

google interview

该文被密码保护。 阅读全文

posted @ 2013-11-14 05:54 Step-BY-Step 阅读(2) 评论(0) 推荐(0) 编辑

Java Memory Basic

摘要: 转自:http://www.blogjava.net/justinchen/archive/2009/justinchen/archive/2009/01/08/248738.htmlGC and Full GCThe garbage collector (GC) detects garbage, defined as objects that are no longer reachable, then reclaims it and makes space available to the running program. The GC typically works in a stop-t 阅读全文

posted @ 2013-11-14 03:23 Step-BY-Step 阅读(229) 评论(0) 推荐(0) 编辑

java Hotspot 内存管理白皮书(中文翻译)

摘要: 转自:http://my.oschina.net/u/568779/blog/1668911引言一个健壮的Java™2平台,StandardEdition(J2SE™)拥有一个自动内存管理机制,它为开发者们屏蔽了复杂的内存管理步骤。本文提供了一个关于javaHotspot虚拟机中内存管理机制的简单概述,它描述了一个可用于垃圾回收的内存管理器,并且提供了关于选择和配置一个回收器以及设置内存区域大小的回收操作。它同样可以作为一个参考书,本文列举了与垃圾回收器行为相关的一些最常用的方法,并且描述了他们之间千丝万缕的关系。第二章节中,我们为读者展示最新的自动内存管理器的概念,在那里我们将讨论手动为数据 阅读全文

posted @ 2013-11-14 03:01 Step-BY-Step 阅读(684) 评论(0) 推荐(0) 编辑

Core Java Notes

该文被密码保护。 阅读全文

posted @ 2013-11-14 02:59 Step-BY-Step 阅读(5) 评论(0) 推荐(0) 编辑

2013年11月13日

Merge Sorted Array

摘要: Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hold additional elements from B. The number of elements initialized in A and B aremandnrespectively. 1 public class Solution { 2 public void merge(int A[], int m, int B[], i... 阅读全文

posted @ 2013-11-13 08:19 Step-BY-Step 阅读(103) 评论(0) 推荐(0) 编辑

Remove Duplicates from Sorted List II

摘要: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3->3->4->4->5, return1->2->5.Given1->1->1->2->3, return2->3.Solution: 指针操作。如果当前val和下一个val相等,则将per指针一直移到和这些val不等的位 阅读全文

posted @ 2013-11-13 07:25 Step-BY-Step 阅读(164) 评论(0) 推荐(0) 编辑

Search in Rotated Sorted Array II

摘要: Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the array.Solution:唯一需要判断的地方是如果刚好在duplicate的地方分开了怎么办,这样的时候 mid没有意义了。 1 public class Solution { 2 public b 阅读全文

posted @ 2013-11-13 06:20 Step-BY-Step 阅读(137) 评论(0) 推荐(0) 编辑

Remove Duplicates from Sorted Array II

摘要: Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ret... 阅读全文

posted @ 2013-11-13 03:56 Step-BY-Step 阅读(191) 评论(0) 推荐(0) 编辑

Subsets II

摘要: Given a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.... 阅读全文

posted @ 2013-11-13 03:42 Step-BY-Step 阅读(156) 评论(0) 推荐(0) 编辑

Subsets

摘要: Given a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,IfS=[1,2,3], a solution is:[ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], []]这题和Combinations一样。 也可以用位运算做。 ... 阅读全文

posted @ 2013-11-13 02:50 Step-BY-Step 阅读(104) 评论(0) 推荐(0) 编辑

2013年11月12日

Climbing Stairs

摘要: You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文

posted @ 2013-11-12 14:24 Step-BY-Step 阅读(129) 评论(0) 推荐(0) 编辑

2013年11月10日

Unique Paths

摘要: A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).How many possible uni 阅读全文

posted @ 2013-11-10 06:23 Step-BY-Step 阅读(137) 评论(0) 推荐(0) 编辑

2013年11月9日

What is the difference between supervised learning and unsupervised learning?

摘要: Machine Learning is a class of algorithms which is data-driven, i.e. unlike "normal" algorithms it is the data that "tells" what the "good answer" is. Example: an hypothetical non-machine learning algorithm for face recognition in images would try to define what a face 阅读全文

posted @ 2013-11-09 02:09 Step-BY-Step 阅读(712) 评论(0) 推荐(0) 编辑

Yelp Interview

该文被密码保护。 阅读全文

posted @ 2013-11-09 02:08 Step-BY-Step 阅读(2) 评论(0) 推荐(0) 编辑

Symantec Interview

该文被密码保护。 阅读全文

posted @ 2013-11-09 02:07 Step-BY-Step 阅读(6) 评论(0) 推荐(0) 编辑

volatile

摘要: Incomputer programming, particularly in theC,C++,C#, andJavaprogramming languages, avariableorobjectdeclared with thevolatilekeywordusually has special properties related to optimization and/or threading. Generally speaking, thevolatilekeyword is intended to prevent the compiler from applying certai 阅读全文

posted @ 2013-11-09 02:01 Step-BY-Step 阅读(187) 评论(0) 推荐(0) 编辑

Public, Private and Protect

摘要: public 意味着在其后声明的所有成员对所有的人都可以取。private 意味着除了该类型的创建者和类的内部成员函数之外,任何人都不能存取这些成员。protect 它与private基本相似,只有一点不同:继承的结构可以访问protected成员,但不能访问private成员。 阅读全文

posted @ 2013-11-09 01:55 Step-BY-Step 阅读(157) 评论(0) 推荐(0) 编辑

2013年11月8日

UNIX command Questions Answers asked in Interview

摘要: UNIX or Linux operating systemhas become default Server operating system and for whichever programming job you give interview you find some UNIX command interview questions there.These UNIX command interview questionsare mostly asked during Java development and Support role interviews on various inv 阅读全文

posted @ 2013-11-08 01:25 Step-BY-Step 阅读(476) 评论(0) 推荐(0) 编辑

Core Java Interview Question Answer

摘要: This is a new series of sharingcore Java interview question and answer on Finance domainand mostly on big Investment bank.Many of these Java interview questions are asked onJP Morgan,Morgan Stanley,BarclaysorGoldman Sachs. Banks mostly asked core Java interview questions from multi-threading, collec 阅读全文

posted @ 2013-11-08 01:23 Step-BY-Step 阅读(960) 评论(0) 推荐(0) 编辑

2013年11月7日

Anagrams

摘要: Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.Solution andPrecautions:First, note what is Anagrams, you can google search it and let’s claim that wordAandBis called anagram to each other if we can get word B(A) from A(B) by rearrangi 阅读全文

posted @ 2013-11-07 13:23 Step-BY-Step 阅读(270) 评论(0) 推荐(0) 编辑

Permutations II

摘要: Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2]have the following unique perm... 阅读全文

posted @ 2013-11-07 12:53 Step-BY-Step 阅读(168) 评论(0) 推荐(0) 编辑

Minimum Window Substring

摘要: Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBANC"T="ABC"Minimum window is"BANC".Note:If there is no such window in S that covers all characters in T, return the emtpy 阅读全文

posted @ 2013-11-07 10:09 Step-BY-Step 阅读(208) 评论(0) 推荐(0) 编辑

工厂模式

摘要: 工厂模式定义:实例化对象,用工厂方法代替new操作。工厂模式是我们最常用的模式了,著名的Jive论坛 ,就大量使用了工厂模式,工厂模式在Java程序系统可以说是随处可见。因为工厂模式就相当于创建实例对象的new,我们经常要根据类Class生成实例对象,如A a=new A() 工厂模式也是用来创建实例对象的,所以以后new时就要多个心眼,是否可以考虑使用工厂模式,虽然这样做,可能多做一些工作,但会给你系统带来更大的可扩展性和尽量少的修改量。1编程开发工厂模式定义我们以类Sample为例, 如果我们要创建Sample的实例对象:Sample* sample=new Sample();可是,实际情 阅读全文

posted @ 2013-11-07 02:08 Step-BY-Step 阅读(226) 评论(0) 推荐(0) 编辑

How do you design object oriented projects?

摘要: what are things you do during the high level design phase (before you begin programming) to determine what are the classes you need (especially ones not based on any 'real world objects') and how will they interact with each other?The steps that I use for initial design (getting to a class d 阅读全文

posted @ 2013-11-07 01:15 Step-BY-Step 阅读(147) 评论(0) 推荐(0) 编辑

What is Object Oriented Design? (OOD)

摘要: Object Oriented Design is the concept that forces programmers to plan out their code in order to have a better flowing program. The origins of object oriented design is debated, but the first languages that supported it included Simula and SmallTalk. The term did not become popular until Grady Booch 阅读全文

posted @ 2013-11-07 01:00 Step-BY-Step 阅读(331) 评论(0) 推荐(0) 编辑

2013年11月6日

Amazon Interview Question: Design an OO parking lot

摘要: Design an OO parking lot. What classes and functions will it have. It should say, full, empty and also be able to find spot for Valet parking. The lot has 3 different types of parking: regular, handicapped and compact.Here is a quick start to get the gears turning...ParkingLot is a class.ParkingSpac 阅读全文

posted @ 2013-11-06 14:48 Step-BY-Step 阅读(469) 评论(0) 推荐(0) 编辑

讨论一道求质数的面试题

摘要: 求2…n的所有质数前置知识:一个数n如果不能被2...n的数除尽,那么n就是一个质数。但是因为某些原因如果n不能被2…根号n的数除尽就足以证明n是质数。又因为某个定理质数只要不被2...根号n之间的质数除尽就可证明其是质数。如:13需要证明其不会被[2,3]除尽就可知其是质数。因为我们求的n会非常大。所以要用例子中的算法。这意味着要把求出的质数保存下来。正题:n非常大20的几十次方之类 给你两台计算机,如何做到在两台计算机上计算用的时间约等于使用一台的时间的一半。注:主要问的是思路 如:如何分割两台计算机分别的计算范围,不涉及具体算法或技术。 阅读全文

posted @ 2013-11-06 13:20 Step-BY-Step 阅读(227) 评论(0) 推荐(0) 编辑

2013年11月2日

Substring with Concatenation of All Words

摘要: You are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without any intervening characters.For example, given:S:"barfoothefoobarman"L:["foo", " 阅读全文

posted @ 2013-11-02 05:46 Step-BY-Step 阅读(157) 评论(0) 推荐(0) 编辑

Chp5: Deduplication

该文被密码保护。 阅读全文

posted @ 2013-11-02 04:28 Step-BY-Step 阅读(2) 评论(0) 推荐(0) 编辑

2013年10月31日

Chp4: Crawlers and Crawling

该文被密码保护。 阅读全文

posted @ 2013-10-31 23:40 Step-BY-Step 阅读(1) 评论(0) 推荐(0) 编辑

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 14 下一页

导航