创建线程后调用execv(Calling execv after creating a thread)
我对线程,进程,execv等都很新。我研究过并发现当你执行execv时,它会占用调用进程的空间。 我想知道当你在main中创建一个线程时会发生什么,然后直接在线程之后调用execv(不是在它完成之前,而是在创建线程之后)。 我知道execv将替换main但这是否意味着它也将替换线程或线程是否能够像正常一样执行和完成?
我要问的一个小例子:
int main(){ printf("hello from main!); char *buffer = "some data"; if(pthread_creat(&mythreadpid, NULL, thread1, buffer){ printf("ERROR!!"); } execv(...) //do execv here } void *thread1(void *buffer){ printf("calling from my thread!"); //do something else }
我测试了这个并且我确实遇到了奇怪的行为,因为我的线程无法完成,因此我想知道这是否是它的原因
I'm very new to threads, processes, execv, etc. I have researched and found that when you execute an execv, it takes the space of the calling process. I am wondering what happens when you create a thread in main, and then call execv, directly after the thread (not before it finishes but right after the thread is created). I know execv will replace main but does this mean that it will also replace the thread or will the thread be able to execute and complete like normal?
Small example of what I'm asking:
int main(){ printf("hello from main!); char *buffer = "some data"; if(pthread_creat(&mythreadpid, NULL, thread1, buffer){ printf("ERROR!!"); } execv(...) //do execv here } void *thread1(void *buffer){ printf("calling from my thread!"); //do something else }
I have tested this and I did experience strange behavior as my thread wouldn't complete so I want to know if this is the reason for it
原文:https://stackoverflow.com/questions/40296502
最满意答案
请参阅此处的逻辑: http : //jsfiddle.net/78ajyyzj/
// work out selected date var dateSelect = $(this).datepicker('getDate'); //used below var dayOfWeek = $.datepicker.formatDate('DD', dateSelect); //shows Monday $('#datepicker-day-of-week').text(dayOfWeek);
然后,您可以使用选择项的ID获取选项并选中/取消选中。
$('.myCheckbox')[index_of_selected_day].checked = true;
UPDATE
创建了一个你想要的jsfiddle示例: http : //jsfiddle.net/mvLx59hb/22/
See the logic here : http://jsfiddle.net/78ajyyzj/
// work out selected date var dateSelect = $(this).datepicker('getDate'); //used below var dayOfWeek = $.datepicker.formatDate('DD', dateSelect); //shows Monday $('#datepicker-day-of-week').text(dayOfWeek);
And then you can grab a option using id of the select item and check/uncheck.
$('.myCheckbox')[index_of_selected_day].checked = true;
UPDATE
Created an example jsfiddle of what you want: http://jsfiddle.net/mvLx59hb/22/
相关问答
更多-
jquery mobile 页面跳转第二次不刷新怎么办[2022-09-17]
checkbox -
jquery mobile本地和环境中显示问题[2023-06-25]
checkbox -
jquery mobile 点击跳转不加载数据怎么回事[2023-11-26]
checkbox -
jQuery Mobile框架弹窗中放表单文本框,整个弹窗区域都会变为文本框的触发焦点,不想这样[2022-03-02]
checkbox -
如何在 jQuery Mobile 的 Listview 中动态移除某一条的图标[2023-09-01]
checkbox -
检查多个复选框jQuery(Check multiple Checkbox jQuery)[2023-11-02]
是的,您的$ .each函数中存在问题。 $.each(result.staff, function() { $("#checkbox[value=" + this + "]").prop('checked'); ^ Here is the issue. }); }); 由于您没有任何与元素相关的id或类,您可以使用元素名称/ +类型来访问它 您必须用您的代码替换 $("input[type='checkbox' ... -
有几件事你需要解决这个问题。 首先,你会想把你的jQuery包装在一个 $(document).ready(function(){ //your code goes here }) 其次,您在mycheckbox的id上缺少一个= 第三,为了设置css的right属性,您首先需要设置position 这里是你的更新代码,似乎在这个小提琴https://jsfiddle.net/yp43vnxz/16/工作 ,它至少会给你一个正确的方向开始 $(document).ready(function(){ $(" ...
-
请参阅此处的逻辑: http : //jsfiddle.net/78ajyyzj/ // work out selected date var dateSelect = $(this).datepicker('getDate'); //used below var dayOfWeek = $.datepicker.formatDate('DD', dateSelect); //shows Monday $('#datepicker- ...
-
当文件上传(多个)完成时,复选框将自动检查(when the file upload (multiple) complete, the checkbox will auto check)[2023-09-18]
$(document).ready(function () { $("#uploadBtn1").on("change", function () { $("#application").attr('checked','checked'); }); $("#uploadBtn2").on("change", function () { $("#application2").attr('checked','checked'); }); }); 你可以为多次上传做同样的事情! $(docume ... -
“所以当我刷新页面时......”当你刷新页面时,整个事情都是从头开始重新加载的。 你的阵列将消失。 如果您想要这种行为,则必须将数组保存在某处( localStorage ,cookies,服务器端等),然后在页面加载时检索该数组。 如果这不是你的意思,你只想拥有一个静态数组,那么你需要访问该数组并检查页面加载时的复选框。 您有相当多的不需要的代码,因此更正后的版本如下所示: // Master array from which checkboxes are created (uses "array li ...