c# (Csharp) threading interview question:- What is thread,background thread and foreground thread ?

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ย. 2011
  • For more such videos visit www.questpond.com
    For more such videos subscribe / questpondvideos
    See our other Step by Step video series below :-
    Learn C# Step by Step goo.gl/FNlqn3
    Learn Angular tutorial step by step tinyurl.com/ycd9j895
    Learn MVC Core step by step :- tinyurl.com/y9jt3wkv
    Learn Design Pattern Step by Step goo.gl/eJdn0m
    Learn Data Science in 1 hour :- tinyurl.com/y5o7qbau
    Learn Power BI Step by Step:- tinyurl.com/y6thhkxw
    Learn MSBI Step by Step in 32 hours:- goo.gl/TTpFZN
    Learn Tableau step by step :- tinyurl.com/kh6ojyo
    Learn SQL Server Step by Step tinyurl.com/ja4zmwu
    Learn SharePoint Step by Step in 8 hours:- goo.gl/XQKHeP
    In this video we will first try to understand what is a thread. We will also demonstrate a simple sample of how threads are created. Finally at the end of the video we demonstrate the difference between background and foreground threads.
    For more such videos visit www.questpond.com
    We are also distributing a 100 page Ebook ".NET Interview Questions". If you want this ebook please share this video in your facebook/twitter/linkedin account and email us on questpond@questpond.com with the shared link and we will email you the PDF.

ความคิดเห็น • 105

  • @dnfvideo
    @dnfvideo  2 ปีที่แล้ว +1

    Do not miss our Interview Question video series
    30 Important C# Interview Questions : th-cam.com/video/BKynEBPqiIM/w-d-xo.html
    25 Important ASP.NET Interview Questions : th-cam.com/video/pXmMdmJUC0g/w-d-xo.html
    25 Angular Interview Questions : th-cam.com/video/-jeoyDJDsSM/w-d-xo.html
    5 MSBI Interview Questions : th-cam.com/video/5E815aXAwYQ/w-d-xo.html

  • @TheDream3873
    @TheDream3873 11 ปีที่แล้ว +3

    Much better than my instructor. Short and to the point!

  • @claudioas2001
    @claudioas2001 12 ปีที่แล้ว +3

    Excellent, simple and easy to remember tutorial. Best explanation I found so far. Thanks, keep your great job.

  • @morsheddld
    @morsheddld 5 ปีที่แล้ว +2

    This was an awesome demonstration of Thread. Totally realised, thx a lot. Very understandable.

  • @EricAnthonyBurnett
    @EricAnthonyBurnett 11 ปีที่แล้ว +2

    Great video! It helped me better understand threading in C#. Thank you!

  • @JonWoo
    @JonWoo 12 ปีที่แล้ว

    Straight to the point and clearly explained. Awesome

  • @billywang5486
    @billywang5486 2 ปีที่แล้ว

    Thanks for the contribution to the C# community!

  • @DineshbabuSengottian
    @DineshbabuSengottian 8 ปีที่แล้ว +19

    Small correction in this vedio : Background thread will live until the life time of last foreground thread belongs to that process.

  • @maxron6514
    @maxron6514 3 ปีที่แล้ว

    This is kept simple and straight forward to the point. Good one

  • @ibknl1986
    @ibknl1986 10 ปีที่แล้ว

    Hi, Your explanation is too good and i find it very informative and understandable just in one watch.Thanks.

  • @PhynnOfficial
    @PhynnOfficial 11 ปีที่แล้ว

    Great tutorial sir. Well done. It helped me a lot!

  • @poojapandey4149
    @poojapandey4149 3 ปีที่แล้ว

    Perfect for beginners in threading concept, great help

  • @tcbetka
    @tcbetka 11 ปีที่แล้ว

    No, I'd say you got it right... The term "threaded application" pretty much implies "parallel" execution of those threads--as long as you assume the threads to be asynchronous. If they are synchronous, then one might argue that the first thread stops to wait for the second and therefore they aren't truly executing at the same time. But with only one core, you don't have much other choice. So while I can see his point, I think you have presented this in an accurate fashion. Thanks!

  • @kalaqueen4659
    @kalaqueen4659 10 ปีที่แล้ว

    greate.ur explaination s simple & clear.

  • @jessy9643
    @jessy9643 6 ปีที่แล้ว

    Nice class !! Worth for listening

  • @GhostManYT
    @GhostManYT 8 ปีที่แล้ว +3

    nicely explained.

  • @anikbutt22
    @anikbutt22 12 ปีที่แล้ว

    beautifully demonstrated.. thank you alot..

  • @gm6902
    @gm6902 2 ปีที่แล้ว

    This video helps me a lot. Thank you.

  • @MikeStock88
    @MikeStock88 ปีที่แล้ว

    Great explanation, thanks for sharing

  • @music130man
    @music130man 4 ปีที่แล้ว

    Excellent video, very informative. Thanks.

  • @robertslamon4403
    @robertslamon4403 5 ปีที่แล้ว

    Nice vid! You made this simple.

  • @shuangwang1689
    @shuangwang1689 7 ปีที่แล้ว

    wonderful ! it helps me a lot , Thank you very much .

  • @jinrajkr4330
    @jinrajkr4330 11 ปีที่แล้ว

    really good explanation on threading.. thnkz for the video.

  • @FlyingBullets
    @FlyingBullets 9 ปีที่แล้ว

    Nice, Thanks! Good one, greetings from Germany

  • @mizantednioc
    @mizantednioc 4 ปีที่แล้ว

    Thank you! very easy to understand

  • @lamarts100
    @lamarts100 12 ปีที่แล้ว

    Great tutorial!!!

  • @eshansingh1
    @eshansingh1 9 ปีที่แล้ว +2

    Thank you for your videos they are very useful!

    • @deepawar_
      @deepawar_ 9 ปีที่แล้ว

      in the starting : sheeshap LOL

  • @manishverma86
    @manishverma86 11 ปีที่แล้ว

    Much better explanation...Thanks. :)

  • @bringaab
    @bringaab 12 ปีที่แล้ว

    great tutorial. more power.

  • @gunarsekaran
    @gunarsekaran 10 ปีที่แล้ว +2

    very usefull...

  • @tayfunaykin4091
    @tayfunaykin4091 9 ปีที่แล้ว

    It's very clear and usefull

  • @joshuazhang6995
    @joshuazhang6995 9 ปีที่แล้ว

    nice one !!! thank you so much

  • @samaraliqazalbash
    @samaraliqazalbash 10 ปีที่แล้ว

    Very helpful thanks

  • @pouriahasheminasab5105
    @pouriahasheminasab5105 11 ปีที่แล้ว

    Thanks for your nice videos.

  • @jeevanwijerathna
    @jeevanwijerathna 11 ปีที่แล้ว

    good explanation. thanks

  • @Jemszie
    @Jemszie 2 ปีที่แล้ว

    very2 helpful for me to understand the Thread. Thanks dude for the video

  • @sumityadav-mt5jz
    @sumityadav-mt5jz 7 ปีที่แล้ว

    nicely explained..👍

  • @darshankalathiya8667
    @darshankalathiya8667 ปีที่แล้ว

    great learning.

  • @ChuckNiddy87
    @ChuckNiddy87 11 ปีที่แล้ว

    Thanks great tutorial

  • @Gary190tube
    @Gary190tube 11 ปีที่แล้ว

    Great video.

  • @manjeetnandal1
    @manjeetnandal1 4 ปีที่แล้ว

    Great sharing!

  • @sathyam34
    @sathyam34 11 ปีที่แล้ว

    Excellent..!

  • @MuhammadQayyumAbro
    @MuhammadQayyumAbro 6 ปีที่แล้ว +2

    She is very sharp.

  • @whimsicalvibes
    @whimsicalvibes 3 ปีที่แล้ว

    Thanks a lot.

  • @chowhaan109nitw
    @chowhaan109nitw 4 ปีที่แล้ว

    Nicely explained

  • @MohanrajPeriasamy
    @MohanrajPeriasamy 11 ปีที่แล้ว

    great video....

  • @rezkhan3366
    @rezkhan3366 2 ปีที่แล้ว

    Awesome!

  • @anjaneya1badrinadh
    @anjaneya1badrinadh 4 ปีที่แล้ว

    Hi Sir,
    Please make video on difference between Finalize vs Dispose in C#

  • @parsalotfy
    @parsalotfy 8 ปีที่แล้ว

    I realize diferent beetwen foreground & Backgroung Threads completly...
    Thanks for your VERY helpful video !

  • @kannitra
    @kannitra 10 ปีที่แล้ว

    great video thanks>........

  • @animeshpatel619
    @animeshpatel619 5 ปีที่แล้ว

    hello can you please upload video on multiple parallel http asynchronous programing using await when all

  • @ChetanChanneCSC
    @ChetanChanneCSC 10 ปีที่แล้ว

    Good one

  • @naukriabhi3
    @naukriabhi3 12 ปีที่แล้ว +2

    Well in the last part of the video..I can see 'The main application has exited' and below that 'Function1 is entered'...How it is possible...I mean as it reaches to the end of the main program first it shouldn't display the 'Function1 is entered' at all.... Is it because of the delay in writing/displaying to the console application (I mean thread reached first to 'Function1 is entered' and then 'The main application has exited' but display wise it looks opposite) or I am missing something....???

  • @killaurnext
    @killaurnext 10 ปีที่แล้ว

    when he had function 1 & 2 = parallel tasks
    when it was just function 1 and explaining foreground and background thread...i guess it technically could be both threaded tasks and parallel tasks (I would go more with threaded tasks since you could argue that there is only one thread)

  • @vaibhavlodha1178
    @vaibhavlodha1178 11 ปีที่แล้ว

    awesome....

  • @ArunSingh-uh5kn
    @ArunSingh-uh5kn 7 ปีที่แล้ว

    can you please describe the timing of thread sleep in this program. Means which function call's when after 4 sec as we see there are in function1 and function 2 calling sequence

  • @kk3528
    @kk3528 2 ปีที่แล้ว

    Very good

  • @bagwerohit
    @bagwerohit 11 ปีที่แล้ว

    Nice one thanxxxxxxxxxxxxxxxxxxx

  • @rainvictorron2413
    @rainvictorron2413 4 ปีที่แล้ว

    Sir,may i ask,how does threading differs with delegate chaining? Thank you in advance.

  • @tcbetka
    @tcbetka 11 ปีที่แล้ว

    I don't think it matters whether or not the threads are foreground or background. As I understand it, that only affects the persistence of the spawned thread when the parent thread terminates...as you've shown in your demonstration.
    I got a lot of information from your video, so thanks again for posting it!

  • @makinggreatbread
    @makinggreatbread 3 ปีที่แล้ว

    good video

  • @drsamsam1104
    @drsamsam1104 3 ปีที่แล้ว

    Does
    Any one have a example of STA threads managing com object with form
    And running other tasks on background threads

  • @ferrarikarthik1
    @ferrarikarthik1 10 ปีที่แล้ว

    S...Because, Parallel code execution concept revolves around the execution of code in multiple processors....But in case of single processor MultiThreding concept(as demonstarted here), the processor executes for a specific time the code in function 1 and function 2. What this implies is that, the processor executes the code in f1 and then for f2. When it is executing f2, f1 is not executed.So, this is not parallel code execution.

  • @saurabhtanwer2166
    @saurabhtanwer2166 ปีที่แล้ว

    Thread means parallel execution? Is not it is time slicing or context switching

  • @RajKumar-nh8ko
    @RajKumar-nh8ko 4 ปีที่แล้ว

    Nice 👍

  • @shaleenshuklass
    @shaleenshuklass 11 ปีที่แล้ว

    so what is use of background thread

  • @bipulabu
    @bipulabu 8 ปีที่แล้ว

    When you run 2 different threads - will they run parallely in the same core processor or will they run on two different processors ?

    • @dnfvideo
      @dnfvideo  8 ปีที่แล้ว

      +bipulabu For technical query please mail us at questpond@questpond.com

  • @dnfvideo
    @dnfvideo  12 ปีที่แล้ว

    Did i mix up ?

  • @daviddbeloved
    @daviddbeloved 11 ปีที่แล้ว

    great. waoooh

  • @mememonster2370
    @mememonster2370 3 หลายเดือนก่อน

    after 12 years
    Task - An opeartion
    Thread - process a Task (or executes an operation)
    Multithreading - process multiple task parallel

  • @Lazy-AI
    @Lazy-AI 8 ปีที่แล้ว +1

    Hiee sir , in ur 1st example i've added IsBackground = true for both the function but Function1 and Function2 is still looping and executing after Main thread has ended. what m i doing wrong ?
    Thread obj1 = new Thread(Function1);
    Thread obj2 = new Thread(Function2);
    obj1.IsBackground = true;
    obj2.IsBackground = true;
    obj1.Start();
    obj2.Start();
    Console.WriteLine("Main application has ended");
    Console.ReadKey();

    • @maringeorgiev4456
      @maringeorgiev4456 8 ปีที่แล้ว +1

      +Saurabh Main thread hasn't ended after displaying its message on the console. It waits for your next command Console.ReadKey(); Delete that, start the app with Ctrl + F5 evth should be fine

  • @shaleenshuklass
    @shaleenshuklass 11 ปีที่แล้ว

    sir please tell me threadstart delegate

  • @OreoCokes
    @OreoCokes 11 ปีที่แล้ว +1

    Great vid, its like taking lessons from Frank Sinatra :D in other words.... thanks.

  • @rutabuga
    @rutabuga 12 ปีที่แล้ว +1

    you should not mix up the definition for threaded tasks and parallel tasks.

  • @WoundedEgo
    @WoundedEgo 12 ปีที่แล้ว

    Why? What is the difference?

  • @VINNUSAURUS
    @VINNUSAURUS 10 ปีที่แล้ว

    can u explain when to use forground and background ?

    • @santoshKoolkarni
      @santoshKoolkarni 10 ปีที่แล้ว

      Use background for tasks that don't involve any user interaction.

    • @santoshKoolkarni
      @santoshKoolkarni 10 ปีที่แล้ว +2

      Also background threads abruptly end when all foreground threads end. So none of the cleanups will be performed including any cleanup in the finally block. So if any cleanup is important, use foreground thread or implement some way to cleanup the background before ending last foreground thread.

    • @VINNUSAURUS
      @VINNUSAURUS 10 ปีที่แล้ว +1

      Santosh Kulkarni Nice :) Thank you :)

    • @srinivasan1482
      @srinivasan1482 10 ปีที่แล้ว +1

      Santosh Kulkarni Really good explanation.

  • @muhammadadnanakmal9590
    @muhammadadnanakmal9590 9 ปีที่แล้ว

    sir i've question if we don't call thread.sleep() method in both Function1 and Function2 Method then what will happen
    and its mandatory that we must call sleep() in threading

    • @MB26566
      @MB26566 7 ปีที่แล้ว

      No it,s not mandatory if u want to stop your thread for some time then you can invoke thread.Sleep() method

    • @ivesmathew2980
      @ivesmathew2980 5 ปีที่แล้ว

      @@MB26566 Thread.Sleep() was used just for demonstration purposes.

  • @bike4aday
    @bike4aday 10 ปีที่แล้ว +1

    in other words

  • @alphandor
    @alphandor 12 ปีที่แล้ว

    control F FIRE!

  • @saabslol
    @saabslol 11 ปีที่แล้ว

    in other words!

  • @PE425
    @PE425 11 ปีที่แล้ว +2

    "She sharp"??

  • @JDavidEfrain
    @JDavidEfrain 11 ปีที่แล้ว

    Great another Hindu tutorial

  • @--Mr.Bombastic--
    @--Mr.Bombastic-- 3 ปีที่แล้ว

    add should. be stop..

  • @Kanakis2016
    @Kanakis2016 ปีที่แล้ว

    Qytgystsyysysghggyggyyytffhgĝhhuuyuyyyyyyyyyhhhu7ùĥ

  • @JDavidEfrain
    @JDavidEfrain 11 ปีที่แล้ว

    Americans invented this shit dude

  • @bogie5464
    @bogie5464 11 ปีที่แล้ว

    Hindu is a religion... not a race. That's like saying "Great another Christian tutorial." He sounds Indian, but I could be wrong. Also he knows his shit that's clear, so I don't mind the accent. I'm not an ignorant American.