System::Threading::Thread kelas
isi
[
bersembunyi
]Thread class
Thread implementation. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.
class Thread : public System::Object
Metode
| Metode | Deskripsi |
|---|---|
| Abort() | Menghentikan thread. Tidak diimplementasikan. |
| get_CurrentCulture() | Mendapatkan kultur thread. |
| static get_CurrentThread() | Mendapatkan objek yang menggambarkan thread saat ini. |
| get_CurrentUICulture() | Mendapatkan kultur antarmuka pengguna yang digunakan oleh thread. |
| get_IsAlive() | Memeriksa apakah thread masih hidup. |
| get_IsBackground() | Memeriksa apakah thread berjalan di latar belakang. |
| get_IsThreadPoolThread() | Memeriksa apakah thread dimiliki oleh pool thread. |
| get_ManagedThreadId() const | Mendapatkan pengenal thread. Dapat diambil dari OS, tetapi jika pengenal thread OS melebihi batas int, id thread dapat bertumpang tindih. |
| get_Name() | Mendapatkan nama thread. |
| get_ThreadState() | Mendapatkan status thread. |
| static GetCurrentThreadId() | Mendapatkan pengenal thread saat ini. |
| GetHashCode() const override | |
| Interrupt() | Menginterupsi thread. Tidak diimplementasikan. |
| Join() | Menunggu thread terkelola. Melakukan penunggu tak terbatas jika diperlukan. |
| Join(int) | Menunggu thread terkelola. Melakukan penunggu terbatas. |
| Join(TimeSpan) | Menunggu thread terkelola. Melakukan penunggu terbatas. |
| static MemoryBarrier() | Menyinkronkan akses memori. |
| operator=(const Thread&) | Menyalin data TLS dari thread yang berbeda. |
| set_CurrentCulture(const SharedPtr<Globalization::CultureInfo>&) | Mengatur kultur thread. |
| set_CurrentUICulture(const SharedPtr<Globalization::CultureInfo>&) | Mengatur kultur antarmuka pengguna yang digunakan oleh thread. |
| set_IsBackground(bool) | Mengatur thread menjadi latar belakang atau latar depan. |
| set_Name(const System::String&) | Mengatur nama thread. |
| static Sleep(int) | Menghentikan thread saat ini selama batas waktu yang ditentukan. |
| static Sleep(TimeSpan) | Menghentikan thread saat ini selama batas waktu yang ditentukan. |
| static SpinWait(int) | Menunggu sejumlah iterasi loop tertentu. |
| Start() | Memulai thread menggunakan objek argumen null. |
| Start(const System::SharedPtr<System::Object>&) | Memulai thread. |
| Thread() | Konstruktor. |
| Thread(ThreadStart) | Konstruktor. |
| Thread(ParameterizedThreadStart) | Konstruktor. |
| Thread(Thread&) | Konstruktor penyalinan. |
| static Yield() | Menyisihkan thread. |
| virtual ~Thread() | Destruktor. |
Catatan
#include "system/threading/thread.h"
#include "system/smart_ptr.h"
int main()
{
auto thread = System::MakeObject<System::Threading::Thread>([]()
{
std::cout << "Child thread ID: " << System::Threading::Thread::GetCurrentThreadId() << std::endl;
System::Threading::Thread::Sleep(200);
});
std::cout << "Main thread ID: " << System::Threading::Thread::GetCurrentThreadId() << std::endl;
thread->Start();
thread->Join();
return 0;
}
/*
This code example produces the following output:
Main thread ID: 2
Child thread ID: 1
*/
Lihat Juga
- Class Object
- Namespace System::Threading
- Library Aspose.Page for C++