- 博客(201)
- 资源 (5)
- 收藏
- 关注
原创 Java实现可GC的JVM(每个模块有运行样例)
Java实现简易JVM github地址 主要模块和样例: 1. 读取并解析class文件,如String、Thread等类(支持jdk8及以下) 部分类可能在demo运行时用到: zvm\bytecode\java\lang\System.class zvm\bytecode\java\io\PrintStream.class zvm\bytecode\java\lang\Threa...
2019-12-26 23:13:21
562
原创 协同过滤-矩阵分解推荐 java实现
这是本人在cousera上学习机器学习的笔记,不能保证其正确性,谨慎参考 看完这几课后 collaborative-filtering collaborative-filtering-algorithm vectorization-low-rank-matrix-factorization 同时参考下面的这篇文章: SVD在推荐系统中的应用详解以及算法推导 后自己用java实现了一下 1
2017-03-14 07:54:14
4399
原创 基于内容的推荐 java实现
这是本人在cousera上学习机器学习的笔记,不能保证其正确性,谨慎参考 看完这一课后Content Based Recommendations 后自己用java实现了一下 1、下图是待处理的数据,代码使用数据和下图一样: 2、思路:对每个用户假定其为一个3维向量(在代码中初始化为[1,1,1]的转置,然后采用梯度下降法不断的对这个3维向量的值进行更新),假设更新到最后的向量值为[0,5,0]的转
2017-03-09 17:25:44
11882
原创 CSAPP 逆向工程试验 bomb
四、实验步骤和结果 1. 输入反汇编命令查看汇编代码(保存在1.txt文件中): 图1 2. 首先找到main函数,发现它调用了从phase1到phase6这六个函数: 图2 由反汇编代码可以知道phase_1为字符串比较,根据下图3打印出0x80497c0得到下图4,故可以得到答案“Publicspeaking is very easy.”:
2016-05-18 00:58:08
1838
1
原创 datalab 数据表示实验
一直都想每天写博客,然后又经常拖,还有这个是作业,用的时间比较久,然后自己又是脑子不灵活的那种,所以写出来的东西可能会有很多错误,欢迎大家指出来交流交流,互相进步。下次实验室bomb,拆炸弹,不知道能不能坚持把它做完,加油~ 1、根据bits.c中的要求补全以下的函数: int bitXor(int x, int y); int tmin(void); int isTmax(int x);
2016-04-30 00:11:58
33145
2
原创 手写(chao)操作系统-编译器的flag
上一节学习了java内存模型解决可见性和有序性问题。这一节看下如何解决原子性问题。原子性问题是线程切换导致的,那么禁止线程切换是否可以避免原子性问题呢?在单核CPU中是这样的,在多核CPU中是不可行的。**操作系统的线程切换是通过CPU中断进行的,可以通过禁止CPU中断来禁止线程切换。**在单核CPU中,如果禁止了CPU线程切换,线程中执行了操作A,进行 ...
2019-08-27 01:20:22
713
1
原创 openjdk调试环境搭建和程序运行
参考: https://blog.csdn.net/faadfafasd/article/details/50539615 https://blog.csdn.net/tjiyu/article/details/53725247 https://my.oschina.net/haogrgr/blog/414825 导入项目到eclipse的选项: File-> New -> Ex...
2019-08-18 19:58:10
1519
原创 JAVA并发编程实战-2Java内存模型:看Java如何解决可见性和有序性问题
学习上篇文章知道,可见性是由缓存导致的,有序性是由编译优化导致的。禁用缓存和编译优化,也就解决了这两个问题。然而设置缓存和编译优化的目的是为了提供性能,直接禁用缓存和编译优化显然是不可行的; 故而需要按需缓存和编译优化。JAVA内存模型本质就是提供了程序员按需缓存和编译优化的方法。这些方法具体为synchronized、final、volatile和6个happens before规则; ...
2019-08-05 22:44:58
399
原创 windows安装使用JITWatch
原来在idea用了JITWatch插件,但是效果不好,换成直接使用。需要先安装hsdis、然后从github拉JITWatch的代码,然后编译使用; 安装hsdis-amd64.dll,hsdis-amd64.dll下载地址,下载后放入如下目录F:\LAMP\Java\jdk1.8.0_45\jre\bin\server,和jvm.dll一起 拉github代码,JITWatch源码地...
2019-08-02 09:18:57
1002
1
原创 JMH使用-查看JAVA的汇编语言
1.使用jmh http://openjdk.java.net/projects/code-tools/jmh/ 2.安装maven,yum install maven 3.执行如下命令,会生成benchmark(基准测试)的test项目: mvn archetype:generate -DinteractiveMode=false -DarchetypeGroupId=org.openjdk...
2019-08-02 08:51:09
508
原创 JAVA并发编程实战-1可见性、原子性、有序性:并发编程BUG的源头
这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入 欢迎使用Ma...
2019-07-31 19:55:55
251
转载 JAVA并发编程实战-0学习攻略
JAVA并发 方法论:描绘全景图,在图中深入到细节 关键词 为什么:性能; 是什么:分工、同步、互斥 细节 1) 分工:一件事分为多个任务,分给多个人同时做; 2) 同步:也叫写作。多个任务间可能有依赖(如A依赖B),当B完成时,A需要被唤醒;当B未完成时,A需要等待。A:wait,future.get()等; B:需要唤醒A,notify;实现基础是管程; 3) 互斥:当多个人写作时...
2019-07-26 08:35:48
187
原创 ElasticSearch通过经纬度进行距离排序的一个坑
做了一个小项目,因为要做全文检索和分词检索,使用mysql分词比较难实现,全文检索用like"%%"太慢了(再加上有联表查询就更慢了),所以选择增加一个elasticsearch6来做实现这两个需求。实现思路是:查询所有数据,然后将数据放到es中,该过程使用logstash实现; 在mysql中存在一个字段location记录地址的经纬度,例"39.904581,116.276554",代表纬度...
2018-10-26 02:34:28
6117
原创 JAVA访问ElasticSearch6 NoNodeAvailableException报错
ElasticSearch6 NoNodeAvailableException报错 java访问代码: public class ElasticSearch { public static void main(String[] args) throws UnknownHostException { // 设置集群名称 Settings settings ...
2018-10-20 04:07:46
755
1
转载 对《假笨说-又抓了一个导致频繁GC的鬼--数组动态扩容》实践
对《假笨说-又抓了一个导致频繁GC的鬼–数组动态扩容》实践 本文根据此文章进行操作,学习jvm相关的知识:假笨说-又抓了一个导致频繁GC的鬼–数组动态扩容 1、用到的jvm参数: -Xmx550M -Xms550M -Xmn200M heap堆最大550m,初始heap大小为550m,最大新生代大小为200m; UseConcMarkSweepGC :This flag is...
2018-08-29 09:09:26
733
转载 static synchronized 和 synchronized 的实例
1、 synchronized是对类的当前实例进行加锁,防止其他线程同时访问该类的该实例的所有synchronized块,注意这里是“类的当前实例”, 类的两个不同实例就没有这种约束了。那么static synchronized恰好就是要控制类的所有实例的访问了,static synchronized是限制线程同时访问jvm中该类的所有实例同时访问对应的代码快。 2、 实例1: 一个日本作者-结成
2017-11-19 14:01:50
404
转载 JAVA中的volatile
一、Java并发中的3个概念: 1.原子性:即一个操作或者多个操作 要么全部执行并且执行的过程不会被任何因素打断,要么就都不执行。举个最简单的例子,大家想一下假如为一个32位的变量赋值过程不具备原子性的话,会发生什么后果?x = 10; //语句1 y = x; //语句2 x++; //语句3 x = x + 1; //语句4语句1是直
2017-11-18 22:36:38
321
原创 Ubuntu jdk、eclipse的安装和从github导入project
一、jdk安装1、jdk的安装,在官网下载jdk8,注意jdk9中没有jre文件夹,采用这里的方式安装是不行的。例如我下载的是:jdk-8u151-linux-x64.tar.gz; 2、下载完之后解压缩,然后在/opt中创建jvm目录,使用“ sudo mv jdk1.8.0_151 /opt/jvm”将文件jdk1.8.0_151转移到“/opt/jvm”目录中;3、使用“ gedit ~/.
2017-11-01 21:27:18
458
原创 mysql中union、union all的用法实例
1、建表数据:create table a(fname varchar(30),lname varchar(30),addr varchar(30)) insert into a values ("a_fname1","a_lname1","a_addr1"); insert into a values ("a_fname2","a_lname2","a_addr2"); insert into a
2017-11-01 18:07:14
2421
原创 win10下通过wubi.exe安装ubuntu
1、点击 这里 下载一个 wubi1710r327.exe; 2、执行这个程序(我提前空出了一个盘用于安装Ubuntu),如下选择,安装之后,选择立即重新启动: 3、重启后会进入下图安装页面: 4、但是会出现重复出现一个错误,实际上这个错误并不影响安装使用,如下图,错误“blk_update_request:i/0 error , dev loop2, sector xxxx”: 5
2017-11-01 10:52:33
24669
3
原创 word-break
1、word-break Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s =”leetcode”, dict
2017-10-29 01:58:57
312
原创 unique-paths-ii
1、来源:unique-paths-iiFollow up for “Unique Paths”: Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as1and0respectivel
2017-10-28 03:12:00
372
原创 minimum-path-sum
1、来源:minimum-path-sumGiven a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move eithe
2017-10-28 02:28:25
276
原创 longest-common-prefix
1、来源:longest-common-prefix Write a function to find the longest common prefix string amongst an array of strings.2、思路在代码中写明了,直接看代码:package leetcode;import java.util.Arrays; /** * 对字符串排序,假如几个字符串前缀相同,那
2017-10-27 22:34:45
368
原创 permutations
1、题目: 链接:permutations Given a collection of numbers, return all possible permutations. For example, [1,2,3]have the following permutations: [1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2], and[3,2,1].2、思路
2017-10-27 17:45:08
349
原创 two-sum
1、来源:two-sumGiven an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the ta
2017-10-27 11:39:02
290
原创 类加载器
1、JAVA虚拟机提供了3个类加载器,BootStrap(c++实现,嵌入在jvm内核中)、ExtClassLoader、APPClassLoader加载器; 2、测试代码:/** * 有3中类加载器,BootStrap(c++实现,嵌入在java内核中),ExtClassLoader,APPClassLoader * @author Rail * */ public class Clas
2017-10-25 02:09:34
429
原创 Intellij中使用代理
Intellij中使用maven在一些网站不能下载,例如下面的错误Connection timed out: connect -> [Help 1]: [ERROR] Plugin org.apache.maven.plugins:maven-surefire-plugin:2.17 or one of its dependencies could not be resolved: Failed t
2017-10-24 17:24:30
2793
原创 parallel programming in java introduce
希望自己能坚持,拿到证书 1、本门 课将要学习: task parallelism functional parallelism loop parallelism data parallelism2、parallelism(并行)和concurrency(并发)的区别:
2017-10-24 17:05:15
383
原创 rotate-list
1、来源:rotate-listGiven a list, rotate the list to the right by k places, where k is non-negative. For example: Given1->2->3->4->5->NULLand k =2, return4->5->1->2->3->NULL.2、思路,递归的本质是栈,例子中进栈1、2、3、4、5,
2017-10-24 08:55:40
303
原创 sort-colors
1、来源:sort-colorsGiven 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 t
2017-10-24 01:10:18
394
原创 climbing-stairs
1、来源: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?2、思路: 直接
2017-10-24 00:43:03
459
原创 partition-list
1、来源:partition-list 牛客网Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of t
2017-10-24 00:31:44
377
原创 merge-sorted-array
1、来源: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
2017-10-24 00:20:18
360
原创 binary-tree-zigzag-level-order-traversal
1、来源:binary-tree-zigzag-level-order-traversal牛客网Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alt
2017-10-24 00:06:22
354
原创 construct-binary-tree-from-preorder-and-inorder-traversal
1、来源:construct-binary-tree-from-preorder-and-inorder-traversal Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tr
2017-10-22 09:56:58
337
原创 construct-binary-tree-from-inorder-and-postorder-traversal
1、链接:这里写链接内容来源:牛客网Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.2、思路,通过中序和后序来构建树: 前序的第一个元素为当前根结点root; 在后序中
2017-10-22 09:45:14
396
原创 convert-sorted-array-to-binary-search-tree
1、来源:convert-sorted-array-to-binary-search-tree 牛客网Given an array where elements are sorted in ascending order, convert it to a height balanced BST.2、思路: 二分查找,注意如果数组的length为偶数,则作为根结点的是右边的元素; 当前根结点的左右子结
2017-10-22 08:57:04
263
原创 convert-sorted-list-to-binary-search-tree
1、链接:convert-sorted-list-to-binary-search-tree 来源:牛客网Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.2、思路:通过快慢指针找到中间结点,将中间结点设置为空(注意设置该结点为空,需
2017-10-21 01:32:57
265
原创 balanced-binary-tree
1、链接:balanced-binary-tree来源:牛客网Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtre
2017-10-21 01:20:18
283
LC-3 Editor和LC-3 Simulator
2015-04-23
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅