Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <boost/thread/thread.hpp>
- #include <unistd.h>
- using namespace std;
- #define LICZBAPUNKTOW 10
- double a = 0;
- double b = M_PI;
- double wynik = 0.0;
- void calkaSinus() {
- cout << "wątek pracuje..." << endl;
- double h = (b - a);
- double s = sin(a);
- for (int i = 1; i < LICZBAPUNKTOW; i++) {
- usleep(1000);
- s += s * sin(a + i * h);
- }
- s += s * sin(b);
- wynik = s * h / 2;
- cout << "wątek się zakończył" << endl;
- }
- int main() {
- boost::thread watek(calkaSinus);
- cout << "Sprzętowa współbierzność" << boost::thread::hardware_concurrency() << endl;
- cout << "ID wątku:" << watek.get_id() << endl;
- watek.join();
- cout << "wynik= " << wynik << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement