主题 [英] Threads

查看:88
本文介绍了主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是线程的新手,但对c来说一般都很好。我正在尝试运行一个可能需要一段时间的程序,但系统本身并没有返回

,直到程序完成。我认为线程可以工作,因为我可以发送系统在一个线程上运行然后继续该程序。我试图尝试
,但它看起来就像只运行系统一样。 byu

本身,但它给了我一个分段错误并退出。有人可以请

告诉我如何正确地做到这一点吗?


哦,如果重要的话,我试图在gtk回调中做到这一点。


tia,

poly-p man

解决方案



Poly-poly man写道:


我是线程的新手,但我对c一般都很好。我正在尝试运行一个可能需要一段时间的程序,但系统本身并没有返回

,直到程序完成。我认为线程可以工作,因为我可以发送系统在一个线程上运行然后继续该程序。我试图尝试
,但它看起来就像只运行系统一样。 byu

本身,但它给了我一个分段错误并退出。有人可以请

告诉我如何正确地做到这一点吗?


哦,如果重要的话,我试图在gtk回调中做到这一点。


tia,

poly-p man



天哪,男人,不要''你知道C咒语:K& R使用1-CPU

机器,所以它将适用于所有我们的后代,现在和永远,

amen。


没关系,沃尔玛最便宜的电脑将很快成为双核AMD的价格。


但是要回答你的问题,你不能用线程来做,你只需要用bb或者某些东西拆掉一个单独的进程。或者在

Unix / Linux上将一个&符号放在你传递给命令的结尾处

system()。

< br>

Ancient_Hacker写道:


Poly-poly man写道:


我'' ma总新手到线程,但我一般都很好用c。我正在尝试运行一个可能需要一段时间的程序,但系统本身并没有返回

,直到程序完成。我认为线程可以工作,因为我可以发送系统在一个线程上运行然后继续该程序。我试图尝试
,但它看起来就像只运行系统一样。 byu

本身,但它给了我一个分段错误并退出。有人可以请

告诉我如何正确地做到这一点吗?


哦,如果重要的话,我试图在gtk回调中做到这一点。


tia,

poly-p man



天哪,男人,不要''你知道C咒语:K& R使用1-CPU

机器,因此它将适用于所有我们的后代,现在和永远,

amen。



我从来没有听说过这样的口头禅也不知道它是如何适用的



原始海报并没有说他在一台机器上工作的价格比一台CPU的价格高一些。


无论如何帖子绝对不在这里。 Poly man I

认为

专用于您的操作系统的新闻组最多可能是
可能

到帮助。


Spiros Bousbouras


Ancient_Hacker写道:


Poly-poly man写道:


>我是线程的新手,但对c来说一般都很好。我正在尝试运行可能需要一段时间的程序,但系统本身不会返回
直到程序完成。我认为线程可以工作,因为我可以发送系统在线程上运行然后继续该程序。我试图尝试,但它看起来就像只运行系统一样。 byu
本身,但它给了我一个分段错误并退出。有人可以告诉我如何正确地执行此操作吗?

哦,如果重要的话,我正在尝试在gtk回调中执行此操作。


天哪,伙计,你不知道C咒语:K& R使用1-CPU

机器,因此它将适用于所有我们的后代,现在和永远,

amen。



这甚至都不接近C口号。


别介意沃尔玛最便宜的电脑很快就会成为

双核AMD。



C:双核AMD的首选语言。


但是为了回答你的问题,你不能用线程来做,你会...... / b
必须分开一个单独的进程,用fork或者某些东西。或者在

Unix / Linux上将一个&符号放在你传递给命令的结尾处

system()。



那更像是它。


S.


I''m a total newbie to threads, but am generally good with c. I''m trying to
run a program that might take a while, but system by itself does not return
until the program is finished. I thought that threads would work, because I
could send system to run on a thread then continue with the program. I
attempted, but it seems too act exactly like just running "system" byu
itself, but it gives me a Segmentation Fault and exits. Can someone PLEASE
show me how to do this correctly?

Oh, and if it matters, I''m trying to do it within a gtk callback.

tia,
poly-p man

解决方案


Poly-poly man wrote:

I''m a total newbie to threads, but am generally good with c. I''m trying to
run a program that might take a while, but system by itself does not return
until the program is finished. I thought that threads would work, because I
could send system to run on a thread then continue with the program. I
attempted, but it seems too act exactly like just running "system" byu
itself, but it gives me a Segmentation Fault and exits. Can someone PLEASE
show me how to do this correctly?

Oh, and if it matters, I''m trying to do it within a gtk callback.

tia,
poly-p man

Heavens, man, don''t you know the C mantra: K & R worked with a 1-CPU
machine, and so it will be for all us descendants, for now and forever,
amen.

Never mind that the cheapest computer at Wal-MArt will soon be a
dual-core AMD.

But to answer your question, you can''t do that with threads, you ''ll
have to spin off a separate process, with fork or somesuch. Or on
Unix/Linux put an ampersand on the end of the command you pass to
system().


Ancient_Hacker wrote:

Poly-poly man wrote:

I''m a total newbie to threads, but am generally good with c. I''m trying to
run a program that might take a while, but system by itself does not return
until the program is finished. I thought that threads would work, because I
could send system to run on a thread then continue with the program. I
attempted, but it seems too act exactly like just running "system" byu
itself, but it gives me a Segmentation Fault and exits. Can someone PLEASE
show me how to do this correctly?

Oh, and if it matters, I''m trying to do it within a gtk callback.

tia,
poly-p man


Heavens, man, don''t you know the C mantra: K & R worked with a 1-CPU
machine, and so it will be for all us descendants, for now and forever,
amen.

I''ve never heard of such a mantra nor do I see how it is applicable
since
the original poster did not say that he works on a machine with more
than
one CPUs.

Anyway the opening post is definitely out of topic here. Poly man I
think
that a newsgroup dedicated to your operating system will be the most
likely
to be of assistance.

Spiros Bousbouras


Ancient_Hacker wrote:

Poly-poly man wrote:

>I''m a total newbie to threads, but am generally good with c. I''m trying to
run a program that might take a while, but system by itself does not return
until the program is finished. I thought that threads would work, because I
could send system to run on a thread then continue with the program. I
attempted, but it seems too act exactly like just running "system" byu
itself, but it gives me a Segmentation Fault and exits. Can someone PLEASE
show me how to do this correctly?

Oh, and if it matters, I''m trying to do it within a gtk callback.


Heavens, man, don''t you know the C mantra: K & R worked with a 1-CPU
machine, and so it will be for all us descendants, for now and forever,
amen.

That''s not even close to the C mantra.

Never mind that the cheapest computer at Wal-MArt will soon be a
dual-core AMD.

C: the language of choice for dual-core AMDs.

But to answer your question, you can''t do that with threads, you ''ll
have to spin off a separate process, with fork or somesuch. Or on
Unix/Linux put an ampersand on the end of the command you pass to
system().

That''s more like it.

S.


这篇关于主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆