Multi-Threading?

Discussion in 'Programming General' started by Esuom, Mar 21, 2009.

Multi-Threading?
  1. Unread #1 - Mar 21, 2009 at 1:58 AM
  2. Esuom
    Joined:
    May 3, 2007
    Posts:
    1,731
    Referrals:
    2
    Sythe Gold:
    0

    Esuom Guru
    Banned

    Multi-Threading?

    Can anyone give me a little bit of information on multi threading in C++? Is there any easy-ish way to do it?
     
  3. Unread #2 - Mar 21, 2009 at 2:26 AM
  4. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

  5. Unread #3 - Mar 21, 2009 at 2:39 AM
  6. Esuom
    Joined:
    May 3, 2007
    Posts:
    1,731
    Referrals:
    2
    Sythe Gold:
    0

    Esuom Guru
    Banned

    Multi-Threading?

    I did, I am looking for a fairly basic tutorial. I am more of a hands on learner :p
     
  7. Unread #4 - Mar 21, 2009 at 3:07 AM
  8. cp
    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0

    cp an cat
    Banned

    Multi-Threading?

    What are you looking to accomplish?

    Threading is complicated in just about every language but can (usually) be simply avoided...
     
  9. Unread #5 - Mar 21, 2009 at 12:31 PM
  10. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    Multi-Threading?

    It's not too complicated in Java... I'd even recommend learning it first there.

    You're probably right though cp in that his needs wouldn't require threading. I think he just wants to learn it anyway.
     
  11. Unread #6 - Mar 21, 2009 at 6:45 PM
  12. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Multi-Threading?

    Threading in .Net is actually fairly easy as well, the only problem I have is Mutex (MUTual EXclusion), and interacting between the main thread and so on.

    But yeah, threading will be hard in C++ to master, so be prepared to spend a long time learning it.
     
  13. Unread #7 - Mar 22, 2009 at 12:39 PM
  14. Esuom
    Joined:
    May 3, 2007
    Posts:
    1,731
    Referrals:
    2
    Sythe Gold:
    0

    Esuom Guru
    Banned

    Multi-Threading?

    Yea, I read a few more guides that I found on google, it isn't really worth my time.


    My problem is, I am trying to grab the source of a page and then find one string in it, the function I am using is just too slow.
     
  15. Unread #8 - Mar 26, 2009 at 12:37 PM
  16. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    Multi-Threading?

    Post what you're using? I'm pretty sure I've done that or something very similar before it was wasn't that badly performing.
     
  17. Unread #9 - Mar 26, 2009 at 7:19 PM
  18. Esuom
    Joined:
    May 3, 2007
    Posts:
    1,731
    Referrals:
    2
    Sythe Gold:
    0

    Esuom Guru
    Banned

    Multi-Threading?

    Code:
    string GetSource(char m_strURL[])
    {
    	if ( m_strURL == "" )
    	{
    		return "";
        }
    
    	HINTERNET hINet, hFile;
    	hINet = InternetOpen("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
    
    	if ( !hINet )
    	{
    		return "";
    	}
    
    	hFile = InternetOpenUrl( hINet, m_strURL, NULL, 0, 0, 0 ) ;
        string m_strContents;
    
    	if ( hFile )
    	{
    		CHAR buffer[1024];
    		DWORD dwRead;
    		while ( InternetReadFile( hFile, buffer, 1023, &dwRead ) )\
    		{
    			if ( dwRead == 0 )
    				break;
    			buffer[dwRead] = 0;
    			m_strContents += buffer;
    		}
    		InternetCloseHandle( hFile );
    	}
    	InternetCloseHandle( hINet );  
        return m_strContents;    
    }
    

    A friend wrote it for me, I don't know if there is a better method?
     
  19. Unread #10 - Mar 27, 2009 at 1:38 AM
  20. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    Multi-Threading?

    That's pretty much functionally equivalent to the code I'd been using. I thought you were saying that searching for the string was slow but I now realize you mean that getting the source is slow and I had that same issue. It's late right now but I'll see if I can write up a better get source tomorrow or the next day using socket programming.

    EDIT: What compiler do you use and what Operating System are you running?
     
  21. Unread #11 - Mar 27, 2009 at 7:36 AM
  22. Esuom
    Joined:
    May 3, 2007
    Posts:
    1,731
    Referrals:
    2
    Sythe Gold:
    0

    Esuom Guru
    Banned

    Multi-Threading?

    Windows Vista and Dev-C++. I will be moving on to VC++ soon enough, but my class requires me to use Dev.
     
  23. Unread #12 - Mar 27, 2009 at 8:08 AM
  24. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Multi-Threading?

    This is sort of off-topic, but may I suggest Code::Blocks? It is a much more up-to-date IDE with a lot more functionality. Dev-C++ is so featureless it's not funny IMHO.

    I'll take a look at your code later as well, although I'm not familiar with Windows functions. I tend to use 3rd-party libraries so I can port things.
     
  25. Unread #13 - Jun 22, 2009 at 1:57 AM
  26. Esuom
    Joined:
    May 3, 2007
    Posts:
    1,731
    Referrals:
    2
    Sythe Gold:
    0

    Esuom Guru
    Banned

    Multi-Threading?

    I know this is an old ass post, and swan is gone, but I figured he may see this.


    My teacher for the class was an old school nazi. She required me to use Dev-C++ and because Namespace std wasn't in our books, we couldn't use it. I failed the exam and went from a 99% in the class to an 80% because I used namespace std on my exam.
     
  27. Unread #14 - Jun 22, 2009 at 4:27 AM
  28. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Multi-Threading?

    Old thread is old. Please don't grave dig.

    EDIT: Reopened due to a request.
     
< Java Help / Teaching | Visual Basic Help? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site