我有一个名为的方法的对象StartDownload(),它启动三个线程.
如何在每个线程执行完毕后收到通知?
有没有办法知道一个(或全部)线程是完成还是仍在执行?
以下算法用于在矩阵中查找盆地.整个问题如下:
给出2-D矩阵,其中每个细胞代表细胞的高度.水可以从较高高度的细胞流向较低的细胞.盆地是指邻居中没有高度较低的单元格(左,右,上,下,对角线).你必须找到最大尺寸的盆地块.
我已经实现了代码.我正在寻找时间复杂性.在我看来,时间复杂度是O(n*m),其中n和m是矩阵的行和列.请验证.
public final class Basin {
private Basin() {}
private static enum Direction {
NW(-1, -1), N(0, -1), NE(-1, 1), E(0, 1), SE(1, 1), S(1, 0), SW(1, -1), W(-1, 0);
private int rowDelta;
private int colDelta;
Direction(int rowDelta, int colDelta) {
this.rowDelta = rowDelta;
this.colDelta = colDelta;
}
public int getRowDelta() {
return rowDelta;
}
public int getColDelta() {
return colDelta;
}
}
private static class BasinCount {
private int count;
private boolean isBasin;
private int item;
BasinCount(int …Run Code Online (Sandbox Code Playgroud) 我对此很陌生。我一直在摆弄一些 T-SQL,现在我正在做一些基本的密码工作。现在,当我这样做时,正如您将在代码中看到的那样,如果您使用重复的用户名,我将其设置为尝试抛出错误,如果没有发现问题并创建帐户,则会显示“用户已创建”消息或类似的东西。那失败了,虽然主键确实阻止了重复用户名的插入,但它无论如何都会增加身份列,让我有 2 个用户,一个用户 ID 为 1,另一个用户 ID 为 17。此外,它不会抛出错误,只是说命令已执行。因此,为了尝试强制错误,我对代码做了一些可能非常意大利面条的事情,现在它在最后给了我一个不正确的语法错误。
确切的错误如标题所示:“‘文件结尾’附近的语法不正确。” 期待对话,或者尝试。”我不知道为什么。我搜索了一下,似乎找不到其他人有这个错误,或者理解为什么它会期望这些事情,所以我迷路了。享受我的意大利面条代码的荣耀吧;如果您能想出一种方法来解决不从存储过程抛出错误的初始问题,而不是修复不正确的语法错误,那也将受到欢迎。
ALTER procedure [dbo].[adduser]
@pUsername nvarchar(50),
@pPassword nvarchar(50),
@responsemessage nvarchar(250) output,
@saveme nvarchar(30) = 'Duplicate username'
as
set nocount on
begin
declare @salt UNIQUEIDENTIFIER=newid()
begin tran
begin try
if exists ((select Username from UserLogins where Username = @pUsername))
begin
rollback tran
raiserror(1337, 16, @saveme)
end
else
begin try
insert into dbo.UserLogins (Username, PasswordHash, Salt)
values(@pUsername, hashbytes('SHA2_512', @pPassword+cast(@salt as nvarchar(36))), @salt)
set @responsemessage='User created'
end try
begin catch
set @responsemessage …Run Code Online (Sandbox Code Playgroud) 考虑以下:
using System;
struct FooEnum {
public static implicit operator TypeCode(FooEnum foo) { return TypeCode.Empty; }
}
struct FooDelegate {
public static implicit operator EventHandler(FooDelegate foo) { return null; }
}
struct FooInt {
public static implicit operator int(FooInt foo) { return 0; }
}
class Foo {
public static void Main(string[] args) {
Console.WriteLine(new FooEnum() == new FooEnum()); // CS0019
Console.WriteLine(new FooDelegate() == new FooDelegate()); // OK
Console.WriteLine(new FooInt() == new FooInt()); // OK
}
}
Run Code Online (Sandbox Code Playgroud)
编译这将产生
错误 CS0019:运算符“==”不能应用于“FooEnum”和“FooEnum”类型的操作数 …