我有一个非常基本的问题:
我们什么时候应该决定为特定类使用Interface还是Class?
例如:说我们有2个班,客户和博士.
在继承(类)中:我们可以将这两个类设置为从父类Person继承.
我们不能对Interface做同样的事吗?说我们有InterfacePerson并且Customer和Doctor都实现了接口吗?
因此,这导致:我们何时决定使用一个而不是另一个,反之亦然?
我正在尝试编写一个脚本,该脚本使用这些pcntl_*函数创建了许多分叉的子进程.
基本上,有一个脚本在循环中运行大约一分钟,定期轮询数据库以查看是否有要运行的任务.如果有一个,它应该在一个单独的进程中分叉并运行该任务,以便父进程不会被长时间运行的任务阻止.
由于可能有大量任务准备好运行,我想限制创建的子进程数.因此,我通过在每次创建变量时递增变量来跟踪进程数(然后暂停,如果有太多),然后在信号处理程序中递减它.有点像这样:
define(ticks = 1);
$openProcesses = 0; // how many we have open
$max = 3; // the most we want open at a time
pcntl_signal(SIGCHLD, "childFinished");
while (!time_is_up()) {
if (there_is_something_to_do()) {
$pid = pcntl_fork();
if (!$pid) { // I am the child
foo(); // run the long-running task
exit(0); // and exit
} else { // I am the parent
++$openProcesses;
if ($openProcesses >= $max) {
pcntl_wait($status); // wait for any child to …Run Code Online (Sandbox Code Playgroud) 我使用3种不同颜色的斜体文字视图
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal" android:id="@+id/submittedBy" android:paddingTop="10dip">
<ImageView android:id="@+id/subByImg"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="left" android:layout_gravity="bottom" android:src="@drawable/submitted_by_arrow"/>
<TextView android:id="@+id/submitLabel"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="left" android:text="Submitted by" android:textStyle="italic"
android:textSize="12sp" android:textColor="@color/gray" android:paddingLeft="5dip"/>
<TextView android:id="@+id/submitName" android:textStyle="italic"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="12sp" android:textColor="@color/maroon_dark" android:paddingLeft="10dip"/>
<TextView android:id="@+id/submitByDate" android:textStyle="italic"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="left"
android:textSize="12sp" android:textColor="@color/gray" android:paddingLeft="10dip"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我想知道每个最后一个角色都没有正确显示中间显示的名称是"丹·巴克兰",它缺少最后一个角色看起来像"丹巴克拉诺"
还告诉我请问如何将textview斜体和粗体都用于..
alt text http://www.freeimagehosting.net/uploads/953d573113.jpg
我想使用Meld解决SVN文件的一些冲突.我正在使用Head版本和我的版本来解决冲突.我无法找到如何进行合并操作并解决冲突.当我右键点击该行时,我只看到复制,粘贴,剪切,向右创建补丁副本,复制到左侧选项.有没有办法做"在我之后复制这条线"或"像我之前复制这条线"那样的?我在Windows上工作时使用了WinMerge.现在我转移到Ubuntu机器并且第一次面对这种情况.请帮助我如何使用Meld解决冲突.
提前致谢
关联数组的关键是动态生成的.我如何获得这样一个数组的"密钥"?
$arr = array ('dynamic_key' => 'Value');
Run Code Online (Sandbox Code Playgroud)
我知道可以通过这样的foreach循环访问它:
foreach ($arr as $key => $val) echo "Key value is $key";
Run Code Online (Sandbox Code Playgroud)
但是,我知道这个数组只有一个键,并且想避免使用foreach循环.是否可以以任何其他方式访问此元素的值?或者获得关键名称?
是否有任何工具可以找到一个页面是否是SEO投诉,如果它没有建议某些内容来制作该页面的SEO投诉?
另请注意,我想在离线页面上进行此研究,即这些页面尚未在网络上.
我无法在WinXP中使用vimscript创建俄语(UTF-8)目录.
例如
:call mkdir("??????")
Run Code Online (Sandbox Code Playgroud)
创建?????????µ?‚名称而不是??????.
我也试过了
:call system("mkdir ??????")
Run Code Online (Sandbox Code Playgroud)
结果相同.
可能吗?
我一直在研究LLVM作为我目前正在实现的语言的新后端.它似乎具有良好的性能,而不是高级生成API,足以支持优化异常优化的低级支持.此外,虽然我自己没有检查过,但Apple似乎已经成功地证明了LLVM用于垃圾收集的多核程序.
到现在为止还挺好.由于我对垃圾收集和多核感兴趣,下一步将是选择一个LLVM多核垃圾收集器.这让我想到了一个问题:什么是可用的?我知道Jon Harrop的HLVM工作,但就是这样.
请注意,我需要跨平台,因此Apple的GC可能不是我想要的(除非有跨平台版本).另请注意,我没有任何反对世界各地的垃圾收集器.
在此先感谢,Yoric
我在UITableView中有一个UILabel.这是我在cellForRowAtIndexPath中编写的代码
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(30.0, 5.0, 250.0, 35.0) reuseIdentifier:CellIdentifier] autorelease];
}
CGRect rect = CGRectMake(30.0, 5.0, 250.0, 35.0);
UILabel *label = [[UILabel alloc] initWithFrame:rect];
label.opaque = NO;
label.font = [UIFont systemFontOfSize:14];
label.numberOfLines = 2;
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor darkGrayColor];
label.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
[label setText:@"Test Message"];
[cell addSubview:label];
[label release];
cell.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
Run Code Online (Sandbox Code Playgroud)
我的目的是将单元格和UILabel的背景设置为透明.
但它没有用.任何人都可以告诉我这里缺少什么
谢谢
桑迪普