会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132477个问题

com.bjsxt.homework.Thread;

JoinThread {
    main(String[] args) {
        System..println();
        Thread  t1 = Thread(A());

        t1.start();
        (i =;i<;i++){
            System..println(Thread.().getName()++i);

            (i == ) {

            {
                t1.join();
            } (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
        System..println();
    }
}
 A Runnable{
    Thread = B();

    run() {
        .run();
        (i =;i<;i++){
        System..println(Thread.().getName()++i);
        {
            Thread.();
        } (InterruptedException e) {
            e.printStackTrace();
        }

        (i==){
            {
                .join();
            } (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }}

}
 B Thread{
     run() {
         (i =;i<;i++){
             System..println(Thread.().getName()++i);
             {
                 Thread.();
             } (InterruptedException e) {
                 e.printStackTrace();
             }
     }

     }
 }


JAVA 全系列/第二阶段:JAVA 基础深化和提高/多线程技术(旧) 21752楼

代码:

com.bjsxt.homework.Thread;

JoinThread {
    main(String[] args) {
        System..println();
        Thread  t1 = Thread(A());

        t1.start();
        (i =;i<;i++){
            System..println(Thread.().getName()++i);

            (i == ) {

            {
                t1.join();
            } (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
        System..println();
    }
}
 A Runnable{
    Thread = B();

    run() {
        .run();
        (i =;i<;i++){
        System..println(Thread.().getName()++i);
        {
            Thread.();
        } (InterruptedException e) {
            e.printStackTrace();
        }

        (i==){
            {
                .join();
            } (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }}

}
 B Thread{
     run() {
         (i =;i<;i++){
             System..println(Thread.().getName()++i);
             {
                 Thread.();
             } (InterruptedException e) {
                 e.printStackTrace();
             }
     }

     }
 }


运行结果:
main线程开始
main正在运行0
main正在运行1
main正在运行2
main正在运行3
Thread-1正在运行!!!0
Thread-1正在运行!!!1
Thread-1正在运行!!!2
Thread-1正在运行!!!3
Thread-1正在运行!!!4
Thread-1正在运行!!!5
Thread-1正在运行!!!6
Thread-1正在运行!!!7
Thread-1正在运行!!!8
Thread-1正在运行!!!9
Thread-1正在运行0
Thread-1正在运行1
Thread-1正在运行2
Thread-1正在运行3
Thread-1正在运行4
Thread-1正在运行5
Thread-1正在运行6
Thread-1正在运行7
Thread-1正在运行8
Thread-1正在运行9
main正在运行4
main正在运行5
main正在运行6
main正在运行7
main正在运行8
main正在运行9
main线程结束

Process finished with exit code 0

请问为什么线程中不能创建线程呢???只有一个Thread1

JAVA 全系列/第二阶段:JAVA 基础深化和提高/多线程技术(旧) 21753楼
Python 全系列/第五阶段:数据库编程/mysql的使用 21755楼

mybatisDemo.zip

image.png

image.png

老师,找不到错误,帮我看下

JAVA 全系列/第六阶段:项目管理与SSM框架/Mybatis 21757楼
Python 全系列/第五阶段:数据库编程/mysql的使用 21759楼

/**
 * 定义馒头类
 */
class mantou2{
    private int id ;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public mantou2(int id) {
        this.id = id;
    }
}

/**
 * 定义缓冲区
 */

class buffer{
    private mantou2[] mt = new mantou2[10];
    private int index ;

    /**
     * 放馒头
     */
    public synchronized void push(mantou2 mantou2){
        while (this.index == this.mt.length){
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        notify();
        this.mt[index] = mantou2 ;
        index++ ;
    }

    /**
     * 取馒头
     */
    public synchronized mantou2 pop(){
        while (this.index == 0){
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        notify();
        this.index--;
        return this.mt[index] ;
    }
}

/**
 * 取馒头线程
 */
class qumantou extends Thread{
    buffer buffer = new buffer();
    public qumantou(com.itbz.buffer buffer) {
        this.buffer = buffer;
    }

    @Override
    public void run() {
        for (int i = 0; i < 10;i++){
            buffer.pop() ;
            System.out.println("取馒头" + i);
        }
    }
}
/**
 * 放馒头线程
 */
class cunmantou extends Thread{
    buffer buffer = new buffer();
    public cunmantou(com.itbz.buffer buffer) {
        this.buffer = buffer;
    }

    @Override
    public void run() {
       for (int i = 0; i < 10;i++){
           System.out.println("存馒头" + i);
           mantou2 mantou2 = new mantou2(i);
           buffer.push(mantou2);
       }
    }
}

public class ProductThread2 {
    public static void main(String[] args) {
        buffer buffer = new buffer();
        cunmantou cunmantou = new cunmantou(buffer);
        qumantou qumantou = new qumantou(buffer);
        cunmantou.start();
        qumantou.start();
    }
}

问题 在主方法中声明两个存取馒头的时候,要对存取馒头两个类进行增加有参构造方法而不能使用默认无参构造方法才能正常,如果使用无参构造方法时,程序会阻塞?为什么?这块不太理解

JAVA 全系列/第二阶段:JAVA 基础深化和提高/多线程技术(旧) 21760楼
JAVA 全系列/第十五阶段:Spring Session会话管理/Spring Session 21761楼

[root@bogon deploy_study]# pip3 install uwsgi==2.0.18 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting uwsgi==2.0.18
  Downloading http://pypi.doubanio.com/packages/e7/1e/3dcca007f974fe4eb369bf1b8629d5e342bb3055e2001b2e5340aaefae7a/uwsgi-2.0.18.tar.gz (801kB)
    100% |████████████████████████████████| 808kB 9.8MB/s 
Installing collected packages: uwsgi
  Running setup.py install for uwsgi ... error
    Complete output from command /usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_lm5vsy4/uwsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-g1ttlatt-record/install-record.txt --single-version-externally-managed --compile:
    /usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'descriptions'
      warnings.warn(msg)
    running install
    using profile: buildconf/default.ini
    detected include path: ['/usr/include', '/usr/local/include']
    Patching "bin_name" to properly install_scripts dir
    detected CPU cores: 2
    configured CFLAGS: -O2 -I. -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_HAS_IFADDRS -DUWSGI_ZLIB -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY -DUWSGI_VERSION="\"2.0.18\"" -DUWSGI_VERSION_BASE="2" -DUWSGI_VERSION_MAJOR="0" -DUWSGI_VERSION_MINOR="18" -DUWSGI_VERSION_REVISION="0" -DUWSGI_VERSION_CUSTOM="\"\"" -DUWSGI_YAML -DUWSGI_SSL -DUWSGI_PLUGIN_DIR="\".\"" -DUWSGI_DECLARE_EMBEDDED_PLUGINS="UDEP(python);UDEP(gevent);UDEP(ping);UDEP(cache);UDEP(nagios);UDEP(rrdtool);UDEP(carbon);UDEP(rpc);UDEP(corerouter);UDEP(fastrouter);UDEP(http);UDEP(ugreen);UDEP(signal);UDEP(syslog);UDEP(rsyslog);UDEP(logsocket);UDEP(router_uwsgi);UDEP(router_redirect);UDEP(router_basicauth);UDEP(zergpool);UDEP(redislog);UDEP(mongodblog);UDEP(router_rewrite);UDEP(router_http);UDEP(logfile);UDEP(router_cache);UDEP(rawrouter);UDEP(router_static);UDEP(sslrouter);UDEP(spooler);UDEP(cheaper_busyness);UDEP(symcall);UDEP(transformation_tofile);UDEP(transformation_gzip);UDEP(transformation_chunked);UDEP(transformation_offload);UDEP(router_memcached);UDEP(router_redis);UDEP(router_hash);UDEP(router_expires);UDEP(router_metrics);UDEP(transformation_template);UDEP(stats_pusher_socket);" -DUWSGI_LOAD_EMBEDDED_PLUGINS="ULEP(python);ULEP(gevent);ULEP(ping);ULEP(cache);ULEP(nagios);ULEP(rrdtool);ULEP(carbon);ULEP(rpc);ULEP(corerouter);ULEP(fastrouter);ULEP(http);ULEP(ugreen);ULEP(signal);ULEP(syslog);ULEP(rsyslog);ULEP(logsocket);ULEP(router_uwsgi);ULEP(router_redirect);ULEP(router_basicauth);ULEP(zergpool);ULEP(redislog);ULEP(mongodblog);ULEP(router_rewrite);ULEP(router_http);ULEP(logfile);ULEP(router_cache);ULEP(rawrouter);ULEP(router_static);ULEP(sslrouter);ULEP(spooler);ULEP(cheaper_busyness);ULEP(symcall);ULEP(transformation_tofile);ULEP(transformation_gzip);ULEP(transformation_chunked);ULEP(transformation_offload);ULEP(router_memcached);ULEP(router_redis);ULEP(router_hash);ULEP(router_expires);ULEP(router_metrics);ULEP(transformation_template);ULEP(stats_pusher_socket);"
    *** uWSGI compiling server core ***
    [thread 1][gcc -pthread] core/utils.o
    [thread 0][gcc -pthread] core/protocol.o
    [thread 0][gcc -pthread] core/socket.o
    [thread 0][gcc -pthread] core/logging.o
    [thread 1][gcc -pthread] core/master.o
    [thread 1][gcc -pthread] core/master_utils.o
    [thread 0][gcc -pthread] core/emperor.o
    [thread 1][gcc -pthread] core/notify.o
    [thread 0][gcc -pthread] core/mule.o
    [thread 1][gcc -pthread] core/subscription.o
    [thread 0][gcc -pthread] core/stats.o
    [thread 1][gcc -pthread] core/sendfile.o
    [thread 1][gcc -pthread] core/async.o
    [thread 0][gcc -pthread] core/master_checks.o
    [thread 1][gcc -pthread] core/fifo.o
    [thread 0][gcc -pthread] core/offload.o
    [thread 1][gcc -pthread] core/io.o
    [thread 0][gcc -pthread] core/static.o
    [thread 0][gcc -pthread] core/websockets.o
    [thread 1][gcc -pthread] core/spooler.o
    [thread 0][gcc -pthread] core/snmp.o
    [thread 1][gcc -pthread] core/exceptions.o
    [thread 0][gcc -pthread] core/config.o
    [thread 1][gcc -pthread] core/setup_utils.o
    [thread 1][gcc -pthread] core/clock.o
    [thread 0][gcc -pthread] core/init.o
    [thread 1][gcc -pthread] core/buffer.o
    [thread 0][gcc -pthread] core/reader.o
    [thread 1][gcc -pthread] core/writer.o
    [thread 0][gcc -pthread] core/alarm.o
    [thread 1][gcc -pthread] core/cron.o
    [thread 0][gcc -pthread] core/hooks.o
    [thread 1][gcc -pthread] core/plugins.o
    [thread 0][gcc -pthread] core/lock.o
    [thread 1][gcc -pthread] core/cache.o
    [thread 0][gcc -pthread] core/daemons.o
    [thread 0][gcc -pthread] core/errors.o
    [thread 0][gcc -pthread] core/hash.o
    [thread 1][gcc -pthread] core/master_events.o
    [thread 0][gcc -pthread] core/chunked.o
    [thread 1][gcc -pthread] core/queue.o
    [thread 0][gcc -pthread] core/event.o
    [thread 1][gcc -pthread] core/signal.o
    [thread 0][gcc -pthread] core/strings.o
    [thread 1][gcc -pthread] core/progress.o
    [thread 0][gcc -pthread] core/timebomb.o
    [thread 1][gcc -pthread] core/ini.o
    [thread 0][gcc -pthread] core/fsmon.o
    [thread 1][gcc -pthread] core/mount.o
    [thread 0][gcc -pthread] core/metrics.o
    [thread 1][gcc -pthread] core/plugins_builder.o
    [thread 1][gcc -pthread] core/sharedarea.o
    [thread 0][gcc -pthread] core/rpc.o
    [thread 1][gcc -pthread] core/gateway.o
    [thread 0][gcc -pthread] core/loop.o
    [thread 1][gcc -pthread] core/cookie.o
    [thread 0][gcc -pthread] core/querystring.o
    [thread 1][gcc -pthread] core/rb_timers.o
    [thread 0][gcc -pthread] core/transformations.o
    [thread 1][gcc -pthread] core/uwsgi.o
    [thread 0][gcc -pthread] proto/base.o
    [thread 0][gcc -pthread] proto/uwsgi.o
    [thread 0][gcc -pthread] proto/http.o
    [thread 0][gcc -pthread] proto/fastcgi.o
    [thread 0][gcc -pthread] proto/scgi.o
    [thread 1][gcc -pthread] proto/puwsgi.o
    [thread 0][gcc -pthread] lib/linux_ns.o
    [thread 1][gcc -pthread] core/zlib.o
    [thread 0][gcc -pthread] core/yaml.o
    [thread 1][gcc -pthread] core/ssl.o
    [thread 0][gcc -pthread] core/legion.o
    [thread 1][gcc -pthread] core/dot_h.o
    [thread 1][gcc -pthread] core/config_py.o
    *** uWSGI compiling embedded plugins ***
    [thread 1][gcc -pthread] plugins/python/python_plugin.o
    In file included from plugins/python/python_plugin.c:1:
    plugins/python/uwsgi_python.h:2:10: 致命错误:Python.h:没有那个文件或目录
     #include <Python.h>
              ^~~~~~~~~~
    编译中断。
    
    ----------------------------------------
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_lm5vsy4/uwsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-g1ttlatt-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-_lm5vsy4/uwsgi/



图片.png


图片.png


老师,我在安装uwsgi时,出现编译终止,然后报错,我在网上也搜不到

Python 全系列/第十二阶段:Python_Django3框架/Django高级 21762楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637