C#占用cpu资源,把电源变成暖手宝
效果如图:

1FY3MLJ}2ZK34@~L$O)D~{3.png

代码如下:

    using System.Threading;
    
    namespace 占用cpu资源
    {
        class Program
        {
            static void Main(string[] args)
            {
                Thread a = new Thread(new ThreadStart(XianChengYi));
                a.Start();
                Thread b = new Thread(new ThreadStart(XianChengYi));
                b.Start();
                Thread c = new Thread(new ThreadStart(XianChengYi));
                c.Start();
                Thread d = new Thread(new ThreadStart(XianChengYi));
                d.Start();
                Thread e = new Thread(new ThreadStart(XianChengYi));
                e.Start();
                Thread f = new Thread(new ThreadStart(XianChengYi));
                f.Start();
                Thread g = new Thread(new ThreadStart(XianChengYi));
                g.Start();
                Thread h = new Thread(new ThreadStart(XianChengYi));
                h.Start();
                Thread i = new Thread(new ThreadStart(XianChengYi));
                i.Start();
                Thread j = new Thread(new ThreadStart(XianChengYi));
                j.Start();
                Thread k = new Thread(new ThreadStart(XianChengYi));
                k.Start();
                Thread l = new Thread(new ThreadStart(XianChengYi));
                l.Start();
                Thread m = new Thread(new ThreadStart(XianChengYi));
                m.Start();
                Thread n = new Thread(new ThreadStart(XianChengYi));
                n.Start();
                Thread r = new Thread(new ThreadStart(XianChengYi));
                r.Start();
            }
    
            private static void XianChengYi()
            {
                while (true)
                {
                    string s = "asdahsdjah";
                    string m = "ashjdjkahskdh";
                    s = s + m;
                }
            }
        }
    }
最后修改:2021 年 01 月 12 日 02 : 51 PM
如果觉得我的文章对你有用,请随意赞赏