是调用新的Runnable,还是调用新的Class Safe进行内存管理?(is Calling new Runnable, or Calling new Class Safe For Memory Management?)
你好伙计们希望你有一个美好的一天,我有和后台工作的接口,在其中一个方法,它读取一行字符串并调用实现类的方法,如下所示:
while ( (receivedString = bufferedReader.readLine()) != null && activity != null) { activity.OnFileRowRead(receivedString, stmt, count); count++; }
它被称为100万次,该方法当前返回一个布尔值,因此它是线程安全的,但这种方式明显较慢。 方法是这样的:
if(row != null && row.contains("/.~n/")){ String [] splitted = row.split("\\/.~n/"); for (String str : splitted){ String[] spl = str.split("\\/.nn/"); if(spl.length == 8){ int version = Integer.valueOf(NotNull(spl[7])); stmt.bindLong(1, Integer.valueOf(NotNull(spl[0]))); stmt.bindLong(2, version); stmt.bindString(3, NotNull(spl[3])); stmt.bindDouble(4, Double.valueOf(NotNull(spl[1]))); stmt.bindDouble(5, Double.valueOf(NotNull(spl[2]))); stmt.bindString(6, NotNull(spl[4])); stmt.bindString(7, NotNull(spl[5])); stmt.bindString(8, NotNull(spl[6])); stmt.bindString(9, version == 0 ? MapActivity_Database.STATUS_UNAVAILABLE : MapActivity_Database.STATUS_AVAILABLE); stmt.execute(); str = null; stmt.clearBindings(); count ++; } } splitted = null; } return true; }
现在我正在考虑实现这个的类的方法,创建一个新类并返回布尔值或运行一个新的runnable,并返回值,方法很快,你可以看到,但是1百万太多了,是吗内存和线程安全吗? 我的意思是gc能够回收这些吗?
hello guys hope you having a nice day, i have and interface that works in background , on one of its methods , it reads a line of string and calls a method of implemented class, like this :
while ( (receivedString = bufferedReader.readLine()) != null && activity != null) { activity.OnFileRowRead(receivedString, stmt, count); count++; }
and it is called for like 1million times,the method currently returns a boolean, so it be thread safe, but it is obviously slower this way. the method is this :
if(row != null && row.contains("/.~n/")){ String [] splitted = row.split("\\/.~n/"); for (String str : splitted){ String[] spl = str.split("\\/.nn/"); if(spl.length == 8){ int version = Integer.valueOf(NotNull(spl[7])); stmt.bindLong(1, Integer.valueOf(NotNull(spl[0]))); stmt.bindLong(2, version); stmt.bindString(3, NotNull(spl[3])); stmt.bindDouble(4, Double.valueOf(NotNull(spl[1]))); stmt.bindDouble(5, Double.valueOf(NotNull(spl[2]))); stmt.bindString(6, NotNull(spl[4])); stmt.bindString(7, NotNull(spl[5])); stmt.bindString(8, NotNull(spl[6])); stmt.bindString(9, version == 0 ? MapActivity_Database.STATUS_UNAVAILABLE : MapActivity_Database.STATUS_AVAILABLE); stmt.execute(); str = null; stmt.clearBindings(); count ++; } } splitted = null; } return true; }
now i am thinking that method on the class that implemented this, creates a new class and returns the boolean value or runs a new runnable , and returns value , the method is fast as you can see , but 1million is too much yet, is it safe for the memory and thread to do so? i mean will gc be able to recycle these ?
原文:https://stackoverflow.com/questions/28453998
最满意答案
input[type="radio"]:checked+label{ ..... } //a label that immediately follows an input of type radio that is checked
input[type="radio"]:checked+label{ ..... } //a label that immediately follows an input of type radio that is checked
相关问答
更多-
你会想要使用width函数: var articles = $('#showroom ul').width() / 245; jQuery width()函数。 You'll want to use the width function: var articles = $('#showroom ul').width() / 245; jQuery width() function.
-
这是新的lambda表达式的语法的一部分,将在Java 8中引入。有几个在线教程可以挂起它,这里是一个链接 。 基本上, ->将参数(左侧)与实际表达式(右侧)分离。 That's part of the syntax of the new lambda expressions, to be introduced in Java 8. There are a couple of online tutorials to get the hang of it, here's a link to one. Bas ...
-
input[type="radio"]:checked+label{ ..... } //a label that immediately follows an input of type radio that is checked input[type="radio"]:checked+label{ ..... } //a label that immediately follows an input of type radio that is checked
-
尝试: $("#resume_holder") .contents() .find('body') .children() .css('font-size', '+=' + ui.value); (如果你使用jQuery> = 1.6) 根据文档为CSS: 从jQuery 1.6开始,.css()接受与.animate()类似的相对值。 相对值是以+ =或 - =开始的字符串,用于递增或递减当前值。 例如,如果一个元素的填充左边是10px,则.css(“padding-le ...
-
-@和+@只是一元-和+的方法名称。 如果您想重新定义它们,请将它们作为方法调用,这就是您需要引用它们以将它们与二进制-和+区分开的方式。 -@ and +@ are simply the method names for unary - and +. If you want to redefine them, invoke them as methods, etc., that's how you need to refer to them to distinguish them from binary ...
-
在代码的上下文中, <=不是关系运算符,它是赋值运算符 。 Verilog中有两种类型的赋值: 阻止 : = 非阻塞 : <= 在Verilog设计中,你 始终对组合逻辑使用阻塞分配 始终对顺序逻辑使用non_blocking赋值 如果不这样做,那么模拟将是不确定的 - 每次运行时它的行为都不一定相同。 当然,这并不好。 那么,为什么呢? 好吧,首先,您必须了解Verilog有4个调度区域 : from prev time step | ACTIVE | ...
-
.css还接受一个对象: $(this).css(circle.includesXY(e.pageX, e.pageY) ? { property1: 'value1', property2: 'value2' } : { property1: 'value3', property2: 'value4' } ); .css also accepts an object: $(this).css(circle.includesXY(e. ...
-
这是文档 ,这里有一个相应的答案:“ CSS使用:不是带CLASS的ID ”: doc.css('div:not(#foo)') 会给你所有id不是foo的div。 doc.css('*:not(#foo)') 将为您提供id不是foo所有节点。 doc.css('div:not([id*="foo"])') 会给你所有id不包含foo的div。 require 'nokogiri' doc = Nokogiri::HTML('你可能不会使用postgis,而是使用旧的earthdistance延伸 point <@> point float8给出地球表面两点之间的法定英里距离。 这使用点类型而不是地理/几何。 You're likely not using postgis, but the old earthdistance extension point <@> point float8 Gives the distance in statute miles between two points on the Earth's ...它传递parseError变量的地址,以便可以通过间接设置它。 但是在Swift 2.0中你不会在这种情况下使用它; 你会try使用try 。 It passes the address of the parseError variable so that it can be set by indirection. But you won't be using it in this situation in Swift 2.0; you'll use a try instead.
相关文章
更多- CLR Via C# 3rd 阅读摘要 -- Chapter 21 – Automatic Memory Management (Garbage Collection)
- Hadoop 解除 NameNode is in safe mode
- Hadoop 解除 “Name node is in safe mode”
- tomcat线程一直处于RUNNABLE,不接受请求
- 【转】Java's hashCode is not safe for distributed systems
- 如何卸载assembly?或者class
- 软件项目风险管理(Project Risk Management)
- 关于mysql数据库memory表数据重复问题
- java反射详解(一)_Class类
- Hadoop 解除 “Name node is in safe mode”
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。