-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSharp_张师浩_无22 #8
base: main
Are you sure you want to change the base?
Conversation
@@ -11,8 +11,8 @@ public static void Main(string[] args) | |||
new Thread | |||
( | |||
() => | |||
{ | |||
Console.WriteLine("A Start: "+(a.Start(2000)).ToString()); | |||
{//此处进行了一定修改,否则从原理上好像达不到示例输出效果 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
显然是代码存在bug啊
private static long startTime = 0; | ||
|
||
private static long bar = 0;//Environment.TickCount64; | ||
private static long req = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
怎么能用static呢?
if(bar > req) | ||
bar = req; | ||
return (bar, req); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有采用任何锁或者原子操作保证线程安全
|
||
private static long startTime = 0; | ||
|
||
private static long bar = 0;//Environment.TickCount64; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bar完全可以作为局部变量,不需要作为字段
/// </summary> | ||
public void Set0() | ||
{ | ||
bar = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这没有任何意义啊
bar = Environment.TickCount64 - startTime; | ||
if (bar < req) | ||
{ | ||
bar = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有任何意义的操作,没有实现TrySet0的功能
请想明白如何实现进度清零的目标
No description provided.