Home » Community » Newbie corner » Simple thread example
Re: Simple thread example [message #29582 is a reply to message #29577] |
Mon, 01 November 2010 22:08   |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
dolik.rce wrote on Mon, 01 November 2010 12:59 | Hi Neilson,
1. First a hint: you can search in package selection dialog and in help inside theide. It is usually faster (and as it seems even more reliable ) than windows file search 
Probably simplest possible example suiting your needs:#include <Core/Core.h>
using namespace Upp;
void ThreadFn(){
while(!Thread::IsShutdownThreads()){
Cout()<<"doing something here\n";
Sleep(1000);
}
}
CONSOLE_APP_MAIN{
Thread::Start(callback(ThreadFn));
Sleep(4000);
Thread::ShutdownThreads();
}
2. Note that you have to set MT flag to compile it (otherwise Thread is not defined).
If you need finer control of the thread, you can also use little bit different syntax: Thread t;
t.Run(callback(ThreadFn)); The variable t can than be used for example to Wait() for the thread to end or set its priority(win32 only).
Best regards,
Honza
|
Thanks Honza, that is a great help.
1. TheIde "Search" works good. Even Win XP will not search in Java files but Eclipse will.
2. Project->Main package configuration->right click->Append row->MT
The upp file now has:
mainconfig
"" = "GUI",
"" = "MT";
I will try working your code into my app.
Thanks (much)
Neil
edit: One thing I tinkered with in Python was to print each line of a file, stop it, and rewind (from that point read the previous lines.
I did not get that in the Java app but will in C++, it interacts with a display app that replays a track on a moving map.
I will include a link to the app in "Applications" on this forum when I get it to work.
[Updated on: Mon, 01 November 2010 22:25] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat Jul 19 12:23:33 CEST 2025
Total time taken to generate the page: 0.04139 seconds
|