pthread_join(&newthread,NULL) gives me error so i used pthread_join(newthread,NULL) and it works. Can anyone explain why it works here but does not work in my case. Thankyou.
@JacobSorber
5 жыл бұрын
It's a typo. It should be pthread_join(newthread, NULL);
@navyjosh1
4 жыл бұрын
@@JacobSorber Ty for the help. Maybe annotate this in the video so noobs like me dont get lost.
@GustavoMontanha
4 жыл бұрын
@@JacobSorber how can it be a typo and still run on your video? do you mean that the code window and the console window are not related at all??? it's all an illusion?
@JacobSorber
4 жыл бұрын
It's not an illusion, just a video editing mistake. When I make a 6-minute video, I usually start with 20-25 minutes of footage that I trim down-so things don't drag, and so it doesn't take me forever to upload. In this case, I think I accidentally edited out the part where it gave me an error and I fixed this. Sadly, KZitem doesn't do video annotations anymore, and they don't let me update the video.
@GustavoMontanha
4 жыл бұрын
@@JacobSorber thanks
@joe2jamaly
5 жыл бұрын
In 6 min I got what I I spent a full lab time to try to execute . Thank u.
@themodernpirate2827
3 жыл бұрын
I'm in the lab right now and feel the same
@intelignet
5 жыл бұрын
You are a very good teacher. Thank you for this! looking forward to more videos about pthreads :)
@youssefgerges9078
3 жыл бұрын
Amazing! Thanks bro. I spent 3 hours with my professor trying to explain that and he faild. You did it in 6 minutes! keep it up. Thanks
@JacobSorber
3 жыл бұрын
You're welcome. Glad it helped!
@alexanderzikal7244
14 күн бұрын
Thanks a lot! Refreshing C, learn Zig and Rust and learning every single day a lot and increase the understanding of all. You are a great teacher!
@carolinaSolid19
4 жыл бұрын
I searched about 12 videos looking for a cohesive explanation on pthreads before I found this one. Now I'm watching the whole series. This is the first video I've found that logically and procedurally explains pthreads and their uses. Great job. You earned a subscriber!
@JacobSorber
4 жыл бұрын
Thanks, and welcome to the channel.
@martinpichardo3985
5 ай бұрын
I'm impressed with how simply you explained a topic that can be way complicated to explain. You are an excellent teacher! Thanks!
@user-qw9gr4cb8z
Жыл бұрын
Hey I’m at last year of my computer science bachelor . I just want to say Thank youuuu for your videos they help me a lot ❤️
@JacobSorber
Жыл бұрын
You're welcome. Glad I could help.
@TMerica199
3 жыл бұрын
I remember having to write my own threading library in C with pthreads (and any other threading APIs) being totally off limits. The “metal” and I got very acquainted to say the least... It was a very valuable learning experience. I’m so thankful for the pthreads library now
@jamesnewton6139
3 жыл бұрын
hi Jacob, very good instructions. good teaching skills. But, in this case i can only get it to work if i use ( instead of ) and i also had to change the last line to: pthread_join(newthread, NULL); ( instead of: pthread_join(&newthread, NULL); which is whats in the video). I also had to compile with the -lpthread option like this: gcc -o thread thread.c -lpthread just thought i share this, incase somebody else has the same issue. i use ubuntu 18.04 on a mac. thanks
@applenews9249
4 жыл бұрын
Ok, I was looking for the definition for threads and processes. I looked soo hard but still couldn't understand. I watched 3 mins of your video and all makes sense now! Thanks:)
@user-ry1ku2zr4l
3 жыл бұрын
This was very useful and I appreciate you making this video. You seem like a wonderful teacher and am so grateful you're sharing your knowledge with the world. I can't believe this video has thumbs down! Wishing you a great 2021 ahead!
@chiragr1336
4 жыл бұрын
Video request: pls make a video where you used parallelization to solve an algorithmic problem from say Google hash code. This will help in using this to solve real problems. Thanks.
@denebvegaaltair1146
2 жыл бұрын
Love how people like you make programming easier to learn for the rest of us. Thanks!
@frankgomez9556
2 жыл бұрын
JacobSorber is a great C language teacher. I’m learning lots of useful programming techniques. Thanks
@JacobSorber
2 жыл бұрын
You're welcome.
@danielskala7956
2 жыл бұрын
If this channel doesnt get 1M subs till summer, I will be sad. Great videos Jacob!
@askhowiknow5527
4 жыл бұрын
No one has a Windows machine “handy”. I only ever have a Windows machine lurking or skulking about.
@JacobSorber
4 жыл бұрын
That's definitely true for me.
@karimkohel3240
4 жыл бұрын
They plot against us at night
@luizfernandorabelo5570
2 жыл бұрын
Great video! The second example is more intuitive.
@TsubasaKato
4 жыл бұрын
Thank you for making this video. I will continue my journey by making a new search algorithm using this knowledge.
@andreasleonidou3620
6 ай бұрын
Very helpful thanks!!
@thiwankapathirana9532
Жыл бұрын
Thank you. This made my understanding about threads so much clear.
@juanperret7044
4 жыл бұрын
I don't think you know how much I love you
@stapler942
2 жыл бұрын
Most people: "I hated math in high school, why did I have to memorize the quadratic formula? What the heck is an imaginary number?" Computer science majors: "...I have seen things. Things I can't unsee. Things like void *(*start_routine)(void*) ."
@globaltechmastery2393
Жыл бұрын
Extremely powerful video
@saveplanet3977
3 жыл бұрын
You really know the subject and concepts and I sincerely follow your tips and guidance. Many thanks for these useful videos.
@santoshsco
3 жыл бұрын
Love your channel for quick interview prep.
@rodrigodisselli4532
5 жыл бұрын
thanks, you save me! my professor make that a lot more difficult to understand at class :(
@mockingbird3809
4 жыл бұрын
Same here, Sometimes Cool Profs like Jacob save our asses!
what a amazing tutorial. You are the best. thank you for quality content
@smh_18
4 жыл бұрын
Woah!you are awesome. Learnt the basics in just five mins!
@danielwait8555
Жыл бұрын
Hi Jacob, I'm an embedded systems engineer and would like to do more work to understand threadding in Windows environement. Any chance you could do a tutorial on MinGW / MSYS and to explain win32 vs posix threads and SEH vs SJLJ exception models, etc. that would be a guide for a newbie. Kind regards, I love the videos
@domste
3 жыл бұрын
Thanks, this was clear and straight to the point
@evenaicantfigurethisout
2 жыл бұрын
I hope this will be a good stepping stone for me to transition to odersky's parallel programming course on Coursera. That course really went over my head
@outrotipo4193
5 жыл бұрын
Nice! Thank you for this. Hope you can continue for a long time to come!
@longtranbao4177
4 жыл бұрын
You just help to do my C project. Thanks you!
@yospa5074
29 күн бұрын
Why do some examples I see pass in &start_routine and some pass in start_routine? Both seem to work.
@shantanu83
2 жыл бұрын
Amazing video, simple and easy.
@sagarkhairnar568
3 жыл бұрын
Loved the way you teaching 👍👌superb
@dipeshsamrawat7957
Ай бұрын
Thank you, man😊
@WaldoTheWombat
Жыл бұрын
So is this all happening in parallel? The processor doesn't switch from thread1 to thread2 because of the sleep?
@thepickicool97
3 жыл бұрын
Better than any of my teachers
@muhammadzakiahmad8069
Жыл бұрын
Great Video, Well Understood👍.
@rudyku-cejin288
7 ай бұрын
What is your programming environment setup? Do you have a video that goes over this? I my self use mobaxterm with vim or just visual studio code.
@randomsoul00
Жыл бұрын
Can we make a thread wait for other thread to complete it's execution by pthread_join Or it is specifically used in main function only
@pathayes2224
3 жыл бұрын
Excellent again
@muaz1236
3 жыл бұрын
@5:04 Couldn't understand the metaphor !
@idk-yl7fn
3 жыл бұрын
Thank you
@eddydecolombia
3 жыл бұрын
More on threads and OS please and thank you
@danielepadrini6731
Жыл бұрын
GOLD! ty so much
@amrtcpp6203
4 жыл бұрын
Thank you so much for this useful video.
@sakurira
3 жыл бұрын
Thank you so much for making these videos.
@JacobSorber
3 жыл бұрын
My pleasure. I'm glad to think they're making a difference.
@luizteixeira6624
2 жыл бұрын
Awesome class, thanks a lot!
@chintusharma1
3 жыл бұрын
Sir why do you use clang.iam using gcc .does clang has better libraries i think both have same number of libries and advantages
@cheexiong8759
3 жыл бұрын
good and sample explanation, Thanks!
@WaldoTheWombat
Жыл бұрын
Is this relevant for c++ or is there a different more popular tool for it?
@Uerdue
2 жыл бұрын
Maybe a "cleaner" design would be to have the main thread creating 2 different threads - one running the "yourturn" function and one running "myturn" - , then joining both of them? Somehow, the asymmetry in calling one function within the main thread and one in a seperate thread, when both are conceptually doing the same (just with different strings) feels "wrong" to me. (Although I'm of course fully aware that this is just meant as a very basic example.)
@yjc149
2 жыл бұрын
you are the best !
@bossman4112
3 жыл бұрын
This is my first time doing threads so this might be a dumb question. In the first example when you used the thread for myTurn how did the initial execution thread go to the next function why didn't both just stay on the same call and call myTurn twice . Is it just that it automatically moved to the next call. Like I would understand if the thread called yourTurn. This way the initial execution thread would still call myTurn but the second thread that was created would call yourTurn.
@pranavrao6370
2 жыл бұрын
After creating a thread how long does it last? Until we call pthread_kill, pthread_cancel or pthread_join?
@JacobSorber
2 жыл бұрын
Yes, or until the thread function returns or calls pthread_exit
@edwardmacnab354
2 жыл бұрын
If you put the pthread_create function after the your_turn function would that not allow the my_turn function inside pthread_create to terminate before main terminated ? you'd then have output like "your turn" , "my turn my turn" , etc. etc. or would you just get "your turn , your turn , your turn" followed by a string of 5 "my turn" ? btw , pthread looks like a really bad idea ! Actually you know what ? I'm going to wait till I start coding C and just try things out and isn't that always the best way anyway ? Thanks for your great videos .
@pranavrao6370
2 жыл бұрын
How do I stop a single thread from terminating within its threaded function until a certain condition is met or until the parent thread calls pthreads_join?
@touseef_akhtar
9 ай бұрын
Instant subscribe!
@shekharmaela2308
3 жыл бұрын
Whats the difference between manual threading via threads.h/pthreads, and using OpenMP to do it for you? When should you use one or the other, what are the performance differences? Jacob Sorber
@kushagrakumar9576
5 жыл бұрын
Execellent introduction.
@Sahilbc-wj8qk
5 жыл бұрын
Amazing intuitive intro.
@JacobSorber
5 жыл бұрын
Glad you enjoyed it!
@DevFrogora
5 жыл бұрын
@@JacobSorber sorry for ping can i get to know which terminal are u using, i like the theme
@JacobSorber
5 жыл бұрын
@@DevFrogora In this video, I was using the platformio-ide-terminal plugin for atom. Using ZSH, with the ohmyzsh themes (I think it's the default theme)
@rhinoshop2169
3 жыл бұрын
Really appreciate it!
@meluobote7664
Жыл бұрын
I'm using your video to learning english😂😂, and programming skills
@logicboard7746
2 жыл бұрын
@4:30 main done before thread
@khalidsaifullahfuad
2 жыл бұрын
Thread is one the scary topic to me. Thank you for explaining it such an easy way 😊
I suppose I am not the first one, but you remind me of Matthew Mcconaughey lmao. You're doing fantastic job with these tutorials. They've really come into use with my software-programming course in c, and really sparked the interest to learn more about c now that I start to come across the cool stuff in it through your videos (let's just say that the basics course for c wasn't the most intriguing part for me :D).
@JacobSorber
4 жыл бұрын
Thanks...I think. You're the first to share that with me. I don't sound like I'm from East Texas, do I? :) Yeah, with so many viewers in so many different stages of learning, some videos are going to be too basic for some and too advanced for others. I'll try to keep mixing things up to keep it interesting for everyone.
@loranceluo2497
4 жыл бұрын
absolutely perfect
@gmailservice9945
3 жыл бұрын
what is the name of this code editor????
@jonaskyman
3 жыл бұрын
I tried this, but in my case, using CYGWIN GCC, I had to flush out the stdout after printf, otherwise it did not print anything. If you can give some insight would be great.
@sigmawolf228
2 жыл бұрын
what kinda font do you use? and vs code theme?
@brooksburris8341
2 жыл бұрын
Hey jacob, I was trying to combine your threads and signals videos and I've run into a question. Whenever I press + C, I noticed that the next iteration of the "my turn" loop starts without waiting the full 2 seconds. I hope that makes sense how I described it. In order to keep this from happening, I thought that making a separate thread with the signal handler would solve this, but it still looks like SIGINT triggers the "my turn" loop in main. I don't really have an idea why this would happen. It seems that the handler and main are two separate entities, so the signal should not have an effect on main. If you have a second I'd appreciate any explanation you have. Thanks!
@srivanikothavadla4606
4 жыл бұрын
Thank you soo much...thanks alot
@sadowizzy1105
4 жыл бұрын
Ooh Metaphors are so Fun
@laibamustafa108
3 жыл бұрын
Can you make a video on threadpools? Thanks for these!
@JacobSorber
3 жыл бұрын
You're welcome. I do talk about thread pools a bit in my multithreaded server series. kzitem.info/news/bejne/p4OE1KmpgaObo6w
4 жыл бұрын
thanks a lot
@sandeeparathnayake9427
4 жыл бұрын
you earned a subscriber thank you!
@JacobSorber
4 жыл бұрын
Thanks! Welcome to the channel.
@alute5532
10 ай бұрын
C gifts (to the universe) : 1. Concurrency: is the same 2. Isolation: none 3.call stack: different 4.memory space : the same Thrrading is OS Dependent Win: createThreads Mac: posix Pthreads example plus bells and whistels woohoo!
@wandererstraining
4 жыл бұрын
Simple and easy! Question for you. Using your code and compiling it with GCC, the program never terminates. myturn() and youturn() both execute until the end, but then the program just hangs until I use ctrl-C. I tried adding a return to the end, to no avail. I tried adding a printf test at the end of it all, but it doesn't print. I tried to add both functions a return. After finishing the threaded function, it just hangs there. Adding an exit(0) at the end of the myturn() function worked, but you didn't do that. Yet, your program terminates when you run it.
@wandererstraining
4 жыл бұрын
Found the problem! pthread_join(&newthread, NULL); That was the issue. On that one, I didn't have to pass the address of newthread, just newthread itself, like so: pthread_join(newthread, NULL); I was getting a warning at compilation, but didn't dig into it because I'm also eating chicken at the same time and am only typing with my non-greasy fingers. :| But yeah. Just the pthread_t for joining threads. Not the address.
@MasterRazz3
4 жыл бұрын
awesome thanks!
@smrtfasizmu6161
2 жыл бұрын
I accidentally crashed my computer once by running a program that I wrote which had an infitie loop which produced threads. This description of what I wrote isn't quite correct but you get the point of more or less what I did.
@JYSERroshanseeam
3 жыл бұрын
you're the best
@JacobSorber
3 жыл бұрын
Thanks. 😀
@fevering8120
4 жыл бұрын
Can someone explain to me how the "yourturn" function was also consistently being repeated while the thread function only included *myturn ?
@phoenixhistory5433
3 жыл бұрын
yourturn is a regular sub executed under the main sub, and it s the only one, the myturn, become a thred, will continue to work, but this doesn't mean that the sub main in the principal thread will be waiting, code execution will continue in the sub. main .
@papaulogamerofc946
4 жыл бұрын
In Windows, if you use gcc, pthread also works.
@themarcvelazquez
2 жыл бұрын
lol why u gotta make it badass now i wanna learn more about c now
@jireff
5 жыл бұрын
Thanks, now I understand:)
@rshrewd8809
4 жыл бұрын
you are awesome, thanks.
@JacobSorber
4 жыл бұрын
You're welcome. Thanks for watching.
@mockingbird3809
4 жыл бұрын
Thank you so much for this amazing video. It saved me a lot of stress!
@manumonkey2712
2 жыл бұрын
how do I install 3rd party libraries for codeblocks? is there any tutorial?
@JacobSorber
2 жыл бұрын
I don't use codeblocks. So, hopefully, someone else can chime in.
@saadileila9331
4 жыл бұрын
can you help me to resolve this: write a program whose main thread creates a thread which reads an integer, given by the user, and returns it to the main thread which displays it
@JacobSorber
4 жыл бұрын
Are you reading the integer from the terminal? From a file? As far as returning it to the main thread, you could use a shared global variable, or the thread's result value (you can get it using pthread_join). What have you tried so far?
@jos3008
4 жыл бұрын
is it possible to do this in c programming, using dev c. i want to make a c program that can play music as the background while the program can still continue like normal, please help me
@videowatcher4852
4 жыл бұрын
awesome vid
@aniruddharora4004
2 жыл бұрын
you have to go over the functions properly, what is pthread_t? what is pthread_create? what are all the parameters? that's what i came to learn and i didn't get that. you just went over one example and with bare minimum information about it. it's just critique, i hope you implement in future videos.
Пікірлер: 172